gpt4 book ai didi

javascript - 模拟 axios 时可以使用 URL 通配符吗?

转载 作者:行者123 更新时间:2023-11-28 16:58:42 25 4
gpt4 key购买 nike

我想知道是否可以使用通配符模拟某些 URL,例如所有以 /auth 开头的 URL。我可以做类似 /auth* 的事情吗?

最佳答案

是的,根据the docs您可以使用正则表达式作为 URL。他们的示例之一与您的用例类似:

Using variables in regex

const usersUri = '/users';
const url = new RegExp(`${usersUri}/*`);

mock.onGet(url).reply(200, users);

关于javascript - 模拟 axios 时可以使用 URL 通配符吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58317444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com