How to use axios in vuex?

index.js

import { post, get } from "./axios.js"

let getList = function index (params) {
  return get("http://localhost/blog/public/index.php/api/home", params)
}

export default {getList}

actions.js

import { getList } from "../api/index.js"
getLists (val) {
    getList.then(res => {
      console.log(res)
    })
}
There is a getList method in the

api file. Now I want to use this getList method in vuex"s action.js. Now prompt "export "getList" was not found in". / api/index.js"

May.06,2022

sent default.


export {getList}


export keyword outputs a variable inside the module, and you can also output a function or class (class). It should be noted that the export command specifies an external interface and must establish an one-to-one correspondence with the variables within the module, for example:

var m = 1;
export m;  // 
export {m};

and export default essentially outputs a variable or method called default, and the system allows you to give it any name.

Menu