I try to use Axios mock adapter to simulate GET to Web API, but it does not work.
The api url looks like something like that:
`/api/forms/${guid}`
I try using Regex, but doesn't work (probably something with the d+):
mock.onGet('/\/api\/forms\/\d+/').reply((config) => {
// the actual id can be grabbed from config.url
console.log(config);
return [200, {}];
});
This work:
mock.onGet('/users').reply((config) => {
// the actual id can be grabbed from config.url
console.log(config);
return [200, {}];
});
Regex should not be quoted in JavaScript.
Try this:
mock.onGet(/\/api\/forms\/\d+/).reply((config) => {
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.