response.data
returned by axios can be used, but why is there another layer of promise? on the outside? Isn"t it more troublesome to write like this when using
? The question I encountered yesterday just saw a person ask the same question, but that person didn"t post the code. I posted the code. Can you explain why you did it? Thank you
get().then(data => {
console.log(data)
})
export function get (url, data = {}) {
return new Promise((resolve, reject) => {
axios.get(url, {params: data})
.then(response => {
resolve(response.data)
}, err => {
reject(err)
})
})
}