1
正在使用angullar2 Django的REST框架。我试图从角客户端发表的字符串:'STR' 对象不是可调用的Django angular2
postAuthCode(code: string) {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
var body ={ "code" : code};
return this.http
.post(this.authCodeUrl, {body},options)
.toPromise()
.then(res => {
console.log("the post response", res);
return res ;
})
.catch(this.handleError);
}
在后台视图类:
class AdwordAuthCode(APIView):
def post(self, request, format=None):
"""
:param request:
:param format:
:return: the credentials from the recieved code
"""
data = request.body('code')
print('data', data)
return Response(data)
,当我在测试客户端,我得到
是的,我做到了,它的工作感谢您的答案 – sila