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