我正在尝试使用axios进行以下api调用,但我不确定如何继续。我能够在邮递员中做到这一点,但是即使它返回200 OK状态,它也不会返回我需要的任何数据,但我还是迷上了axios。
我从邮递员的帖子中拿走了所有这些东西:
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));
},
},
});