There is no response in the console.log
when I run this code, but I don't understand why?
async function deleteUser(){
const deleteUser = await fetch(`http://localhost:8000/restApi/userModel/delete?acc=${id}`)
}
router.delete('/delete', async (req,res)=>{
console.log(JSON.stringify(req.query))
})
The default method of fetch
is a GET request, but on your router you've only specified behavior for a DELETE request.
Not sure which fetch module you're using, but it may have a shortcut such as fetch.delete(url)
- check the docs to be sure. You can also simply change the expected method to a GET with router.get('/delete', ...
, but I wouldn't recommend this - it would make more sense for an API to not have a delete
route, but rather just a route where GET returns the object and DELETE deletes it.
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.