Imagine having a wrapper function for the axios
function - something that needs to be used in every ajax query to keep the code DRY. Here is an example:
import axios from "axios"
import NProgress from "nprogress"
const query = (url, options) => {
NProgress.start()
return axios({
url: url,
method: options.method || "GET",
data: options.data || {}
}).then(() => {
NProgress.done()
})
}
export default query
The issue arises when trying to add another .then
resolver to the query()
function as it does not work. Here is an example:
import query from "./query.js"
query("something", {}).then(() => { console.log("This will never be logged") })
Is there a way to add an additional .then()
to the query()
function?