Handle path parameters #2286
-
Is there an easy way to mock url which includes path parameters like this: |
Beta Was this translation helpful? Give feedback.
Answered by
mastermatt
Feb 1, 2022
Replies: 1 comment
-
This would require regex. Nock doesn't have any special handling for path params. const pathRe = /^\/(?<name>[^/]+)\/getProfile$/
nock('https://bla.com')
.get(pathRe)
.reply(200, (path) -> {
const { name } = path.match(pathRe).groups
return { name }
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mastermatt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This would require regex. Nock doesn't have any special handling for path params.