Is it possible to have a custom function in nuxt-axios
async fetchSomething({ commit }) {
const response = await this.$axios.customGet(
`/blabla`
);
await commit("setVideoData", response);
}
And this customGet()
can have their own baseUrl
and custom headers
Edited to add extra information
This is what i add to plugins/axios.js
as a try for the customGet()
function
export default function({ $axios, store, redirect }) {
$axios.customGet(body => {
console.log("body from custom get", body);
});
}
But is not working and i get this error.
答案 0 :(得分:1)
您收到customGet
错误是因为您正在调用函数plugins/axios.js
(不存在)而不是对其进行定义。
您的export default function({ $axios, store, redirect }) {
$axios.customGet = body => {
/* The logic for customGet goes here */
console.log("body from custom get", body);
};
}
应该如下所示:
jq -r '.contexts[.current_context].mydata' file.json