【发布时间】:2019-08-09 04:48:01
【问题描述】:
Python Django 中的代码:
if len(error) < 1:
return Response(status=HTTP_200_OK)
else:
return Response({"data":error}status=HTTP_400_BAD_REQUEST)
javascript中的代码
if(response.status===200){
alert("ok")
}else if(response.status===400){
alert("not ok")
}
200 ok 时返回code,400 bad request 时什么也不返回。事实上,除了 200_ok 代码之外,似乎没有任何回复消息。有什么解决办法吗?
【问题讨论】:
-
代码正确但需要,返回Response({"data":error}, status=HTTP_400_BAD_REQUEST)。
标签: python django django-rest-framework-jwt