makeMightFail
You also have the option to make your own mightFail
wrapper function. Pass in any async function to makeMightFail
and it will return a mightFail
wrapper function for you to use.
const get = makeMightFail(axios.get);
const [ error, result ] = await get("/posts");
if (error) {
// handle error
return;
}
const posts = result.data
posts.map((post) => console.log(post.title));
const get = makeMightFail(axios.get);
const [ error, result ] = await get("/posts");
if (error) {
// handle error
return;
}
const posts = result.data
posts.map((post) => console.log(post.title));
const get = makeMightFail(axios.get);
const [ error, result ] = await get("/posts");
if (error) {
// handle error
return;
}
const posts = result.data
posts.map((post) => console.log(post.title));
const get = makeMightFail(axios.get);
const [ error, result ] = await get("/posts");
if (error) {
// handle error
return;
}
const posts = result.data
posts.map((post) => console.log(post.title));