在使用Postman:
进行测试时出现问题export const addAdmin = (values) => async (dispatch) => {
var add = localStorage.getItem('user');
const res = await fetch('https://capitalluxurydev.xyz/v1/admin/createadmin', {
method: 'POST',
body: JSON.stringify(values),
headers: {
Authorization: add,
'Content-Type': 'application/json; charset=utf-8',
},
credentials: 'same-origin',
});
try {
const data = await res.json();
console.log(data);
return;
} catch (error) {
console.log(error);
return;
}
};
我一直得到无效JSON结构的响应:
{data: null
error: "invalid json construct"
message: ""
statuscode: 422
}
但是在https://hoppscotch.io/
上工作得很好我是巴西人,所以我会说葡萄牙语,但我会用翻译来帮助你。
Opostman
coloca automatiente naAuthorization
O前缀Bearer [your_yoken]
。tent colocar算法como:
headers: {
Authorization: `Bearer ${add}`,
'Content-Type': 'application/json; charset=utf-8',
}