for Example, Can I do API calls like the Below in nested form??
router.post('/',()=>
{
res.send("Some File1");
router.post('/',()=>{
res.send("Some File2");
})
})
What you are doing is not making API calls but creating API endpoints. This means you have created a REST endpoint at / with POST method.
router.post('/',(req, res) => {
res.send("Some File1");
});
Try this snipet, hope it will worked.
router.post('/')
.then((data) => {
res.send({
dataField1,dataField2
})
})
.then(() => {
return router.post('/')
})
.then((data2) => {
res.send({
data2Field1, data2Field
});
})
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.