JavaScript/axios:修订间差异
来自康健生活
| 第33行: | 第33行: | ||
<blockquote><pre> | <blockquote><pre> | ||
withCredentials: true</pre></blockquote> | withCredentials: true</pre></blockquote> | ||
== 写法 == | |||
<syntaxhighlight lang="javascript"> | |||
axios.all([ | |||
axios.get( | |||
"https://beta-security.design.qihoo.net/api/team?role=editor", | |||
{ | |||
headers: { | |||
Authorization: `Bearer ${localStorage.getItem("token")}`, | |||
"Content-Type": "application/json", | |||
}, | |||
} | |||
), | |||
]) | |||
.then( | |||
axios.spread(function (item) { | |||
alert(item.data); | |||
_self.team = item.data.data; | |||
alert("this is renderData for main.vue. end."); | |||
}) | |||
) | |||
.catch((error) => { | |||
alert(error); | |||
_self.errorMessage = error; | |||
});</syntaxhighlight> | |||
== error == | == error == | ||
* Content-Type 设置失效 | * Content-Type 设置失效 | ||