Axios呼叫Heroku超时



我在我的react应用程序中调用axios,在netflix上托管,删除数据库中的食谱。

const handleDelete = async () => {
if (warn) {
await axios.delete('https://foodeii.herokuapp.com/api/delete/rec', { data: { id: props.recipe[0].ID } }).then((response) => {
console.log('Recipe deleted successfully.')
goBack();
})
} else {
setWarn(true);
alert('You will not be able to restore this recipe after deleting.')
}
}

这是我在heroku上的快递服务器:

// DELETE
app.delete('/api/delete/rec', (req, res) => {
const recipe = req.body.id;
const sqlSelect = `DELETE FROM recipes WHERE ID = ${recipe}`;
db.query(sqlSelect, (err, result) => {
console.log(result);
console.log(err);
});
})

const recipe是DB中recipe的简单ID。DB很小,只有3食谱。

当我进入仪表板时,所有的GET请求在几秒钟内都工作得很好。

但是在这个delete查询中,我在heroku, code=12处得到超时,我甚至没有看到axios调用中的控制台日志

为什么我在使用heroku时总是超时?感谢任何帮助

我没有包含res.send() !!固定的

最新更新