所以我使用axios来向djangoapi发送JSON请求。在
axios({
method: 'post',
url: 'http://127.0.0.1:8000/' + this.state.dataRequestEndPoint,
data: (reqData)
});
在axios呼叫之前,我可以看到请求:
^{pr2}$但是,到了Django:
class TargetClass(APIView):
def get(self, request):
Here request is empty:
(Pdb) request.data
<QueryDict: {}>
(Pdb) request.body
b''
def post(self):
pass
我做错什么了?在
p.S.也尝试用fetch
发送请求:
fetch('http://127.0.0.1:8000/' + this.state.dataRequestEndPoint, {
method: 'POST',
body: reqData,
})
都不管用。在
下面是解决上述问题的方法。显然,axios需要发送参数:
然而,我不知道这个解决方案在安全方面有多好。在
相关问题 更多 >
编程相关推荐