试图了解这两者与axios
库之间的区别。
function doSomething() {
axios.get(url)
.then((response) => process(response))
.catch((error) => handle(error))
}
vs
async function doSomething() {
try {
const response = await axios.get(url);
process(response);
} catch(error) {
handle(error);
}
}
vs
async function doSomething() {
return await axios.get(url);
}
vs
function doSomething() {
return axios.get(url);
}
试图理解这一点,并为消费者编写axios调用的包装器。
谢谢。