I am using Laravel at backend and Aurelia on front. I know this has been answered many times before but none solution is working out for me. I want to send custom messages back in aurelia and extract them. Thing I am trying to do:
//post api
.then(response => response.json())
.then(jsonData => {
if(jsonData.msg== true)
{
document.getElementById('close_add_new_modal').click();
} else {
console.log(`Error!`);
}
});
Every time here I get the exception:
Possible Unhandled Promise Rejection: TypeError: Cannot read property 'json' of undefined
Backend: How I am trying to send msg:
return response()->json(['msg' => 'true']);
To solve the error I referred to this post: Possible Unhandled Promise Rejection. Cannot read property of undefined
Followed, but issue remained same. Could anyone tell me where am I wrong or what is correct way of fetching custom messages?