【发布时间】:2020-04-11 09:21:30
【问题描述】:
我在后端使用 Laravel,在前端使用 Aurelia。我知道这已经被回答过很多次了,但没有一个解决方案适合我。我想在 aurelia 中发回自定义消息并提取它们。 我想做的事:
//post api
.then(response => response.json())
.then(jsonData => {
if(jsonData.msg== true)
{
document.getElementById('close_add_new_modal').click();
} else {
console.log(`Error!`);
}
});
每次在这里我都会遇到异常:
Possible Unhandled Promise Rejection: TypeError: Cannot read property 'json' of undefined
后端:我如何尝试发送消息:
return response()->json(['msg' => 'true']);
为了解决我提到这篇文章的错误: Possible Unhandled Promise Rejection. Cannot read property of undefined
已关注,但问题仍然存在。 谁能告诉我我哪里错了或者获取自定义消息的正确方法是什么?
【问题讨论】: