我有一个这样的API:
app.get('/test', (req, res) => {
console.log("this is test");
});
和另一个API:
app.get('/check', (req, res) => {
//I want to call "test" api without redirect to it.
});
我想在“check”api中调用“test”api而不重定向到“test”api,只需执行“test”api中的功能即可。
以上是示例代码。因为我不想将函数从“test”api 重写为“check”
简单的解决方案是定义一个可以使用两个请求路由调用的方法。
app.get('/test', (req, res) => {
console.log("this is test");
callMeMayBe();
});
callMeMayBe()
{
//Your code here
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)