Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 什么是令牌基桩?_Reactjs_Rest_Api_Django Rest Framework - Fatal编程技术网

Reactjs 什么是令牌基桩?

Reactjs 什么是令牌基桩?,reactjs,rest,api,django-rest-framework,Reactjs,Rest,Api,Django Rest Framework,我想将数据发送到以下URL。我发送从令牌验证收到的令牌,但它给出了“错误请求”错误。你能帮我吗 handleSubmit() { fetch('http://127.0.0.1:8000/api/debt/create',{ method: 'POST', headers: { Authorization: `Bearer ${localStorage.getItem('id_token')}`, 'Content-T

我想将数据发送到以下URL。我发送从令牌验证收到的令牌,但它给出了“错误请求”错误。你能帮我吗

handleSubmit() {
   fetch('http://127.0.0.1:8000/api/debt/create',{
       method: 'POST',
       headers: {
           Authorization: `Bearer ${localStorage.getItem('id_token')}`,
           'Content-Type': 'application/json'
       },
       body: JSON.stringify({
           user: '1',
           customer: '9',
           debtKey: 'b1d9ef1b-45ad-4dc5-80cc-95f7994c0aae',
           createduserKey: '0245abb9-2837-4f37-ae02-9be1b88887ef',
           totalDebt: 789,
           receivedAmount: 115,
           description: 'Debt description',
           paymentDate: '01.01.2019'
       }),
   }).then(response => {
       console.log(response);
       return response.json()
   }).then(json => {
       //this.setState({
       //    user:json
       //});
   });
 console.log("form gönderme ekranına düştü");
}

授权
是一个
。它应该在引号中

headers: {
       'Authorization': `Bearer ${localStorage.getItem('id_token')}`,
       'Content-Type': 'application/json'
   },

授权
是一个
。它应该在引号中

headers: {
       'Authorization': `Bearer ${localStorage.getItem('id_token')}`,
       'Content-Type': 'application/json'
   },

你能在api中发布代码吗?你能在没有JSON的情况下发送body吗?stringify?你能通过postman发出请求吗?@Fatimzm检查这个你能在api中发布代码吗?你能在没有JSON的情况下发送body吗?stringify?你能通过postman发出请求吗?@Fatimzm检查这个