我正在使用Laravel 5.7创建REST API,其alwasys返回302以及带有如下所示HTML代码的Redirection Respose
<!DOCTYPE html><html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="0;url=http://localhost/Ozone/en" />
<title>Redirecting to http://localhost/Ozone/en</title>
</head>
<body>
Redirecting to <a href="http://localhost/Ozone/en">http://localhost/Ozone/en</a>.
</body>
{
"status": false,
"message": "Input are not valid",
"error":
{
"contact_number": ["The contact number has already been taken."]
}
}
我只想要JSON响应
{
"status": false,
"message": "Input are not valid",
"error": {
"contact_number": ["The contact number has already been taken."]
}
}
请帮助我
答案 0 :(得分:0)
如果您want
json响应,则需要在请求标头中包含Accept:application/json
。