Skip to content

How can I get separation by QueryString?  #1334

Description

@JUDONGHYEOK

Our API Url is GET members/signup/exists?nickname={}(for nickname check) and GET members/signup/exists?username={}(for username check)

I can use req.url.searchParams.get() to get nickname or username

But I don't know how to separate url by QueryString

Please tell how I separate url by QueryString

rest.get(/^http:\/\/localhost:(3000|6006)\/members\/signup\/exists/, (req, res, ctx) => {
    console.log(req.url);
    if (!req.url.searchParams.get('username')) {
      return ctx.fetch(req);
    }
    console.log('usernameRequest');
    const id = req.url.searchParams.get('username');

    const existedID = validMemberEmail.find(member => member.ID === id);

    if (existedID) {
      return res(ctx.status(200), ctx.json({ unique: false }));
    }
    return res(ctx.status(200), ctx.json({ unique: true }));
  }),

  rest.get(/^http:\/\/localhost:(3000|6006)\/members\/signup\/exists/, (req, res, ctx) => {
    console.log('first');
    if (!req.url.searchParams.get('nickname')) {
      const nicknameResponse = ctx.fetch(req);
      console.log(nicknameResponse);
    }
    const id = req.url.searchParams.get('nickname');

    return res(ctx.status(200), ctx.json({ nickname: false }));
  }),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions