Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

匹配路径,api地址一样,query不同,如何根据不同的query,返回不同数据 #28

Open
hello-sunbaixin opened this issue Nov 21, 2018 · 1 comment

Comments

@hello-sunbaixin
Copy link

'GET /webpage': {
errno: 0,
data: {
username: '夹发夹',
content: '这是一段评楼'
}
},
'GET /webpage?test=1': {
errno: 0,
data: {
username: '111',
content: '4445'
}
}

@jaywcjlove
Copy link
Owner

@hello-sunbaixin 下面示例参考:

const proxy = {
  'GET /api/user/account': (req, res) => {
    const { ab } = req.query;
    if(ab === 1) {
      return res.json({
        status: '1',
      });
    } else if(ab === 2){
      return res.json({
        status: '2',
      });
    } else {
      return res.json({
        status: '3',
      });
    }
  }
}

// http://127.0.0.1:8080/user/account?ab=1
// http://127.0.0.1:8080/user/account?ab=2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants