vue.js - x-www-form-urlencoded api 调用与 axios
问题描述
我正在尝试使用 axios 进行以下 api 调用,但我不确定如何继续。我能够在邮递员中做到这一点,但我对 axios 感到失望,即使它返回 200 OK 状态,它也没有返回我需要的任何数据。
我从我发布的邮递员帖子中获取了所有这些:
import Vue from "vue";
import Vuex from "vuex";
import axios from "./axios-auth.js";
Vue.use(Vuex);
export default new Vuex.Store({
state: {
username: null,
password: null,
},
actions: {
login(authData) {
console.log(authData);
axios
.post("/?target=&auth_id=&ap_name=", {
login: "login",
username: authData.username,
password: authData.password,
},
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'max-age=0',
'Origin': 'http://10.000.000.01:8080',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
'Referer': 'http://10.000.000.01:8080/',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7',
'Connection': 'keep-alive',
}})
.then(res => {
console.log(res)
})
.catch(error => console.log(error));
},
},
});
解决方案
推荐阅读
- python - keras model.save() 没有保存
- wpf - OIDCClient LogoutAsync 抛出 SemaphoreFullException
- django - 以整数形式获取 CharField 的值
- windows - Torch 未使用启用 CUDA 的 Windows 10 编译
- angular - 私有 http:HttpClient 进出构造函数?
- python - 如何聚合多个多边形opencv
- python - How to get the start and end date period of a data sequence in python?
- redux - 如何在“待定”状态下在“createAsyncThunk”上发送自定义参数?
- html - 嵌入图标字体作为 base64 的问题
- jenkins - 带有 Browserstack 的 Testcafe 在中间停止运行测试