反应 axios ReactJS AXIOS post 不起作用
React axios ReactJS AXIOS post doesn't work
控制台错误 ->
[1]: https://i.stack.imgur.com/xOfUV.png
axios
.post("https://bootcamp-2022.devtest.ge/api/application", {
token: "7e475dfc-0daa-4108-81c8-d6c62a3df4ca",
first_name: JSON.parse(localStorage.getItem("PersonalInfo").first_name),
last_name: JSON.parse(localStorage.getItem("PersonalInfo").last_name),
email: JSON.parse(localStorage.getItem("PersonalInfo").email),
skills: JSON.parse(localStorage.getItem("techskill").skills),
work_preference: JSON.parse(
localStorage.getItem("covid").work_preference),
.then((res) => console.log(res))
.catch((err) => {
console.log(err);
如错误所述,您的 json
有误
这是您当前的代码
first_name: JSON.parse(localStorage.getItem("PersonalInfo").first_name)
这是应该的
first_name: JSON.parse(localStorage.getItem("PersonalInfo")).first_name
您可能想隐藏 api 和令牌 .
控制台错误 -> [1]: https://i.stack.imgur.com/xOfUV.png
axios
.post("https://bootcamp-2022.devtest.ge/api/application", {
token: "7e475dfc-0daa-4108-81c8-d6c62a3df4ca",
first_name: JSON.parse(localStorage.getItem("PersonalInfo").first_name),
last_name: JSON.parse(localStorage.getItem("PersonalInfo").last_name),
email: JSON.parse(localStorage.getItem("PersonalInfo").email),
skills: JSON.parse(localStorage.getItem("techskill").skills),
work_preference: JSON.parse(
localStorage.getItem("covid").work_preference),
.then((res) => console.log(res))
.catch((err) => {
console.log(err);
如错误所述,您的 json
有误这是您当前的代码
first_name: JSON.parse(localStorage.getItem("PersonalInfo").first_name)
这是应该的
first_name: JSON.parse(localStorage.getItem("PersonalInfo")).first_name
您可能想隐藏 api 和令牌 .