'JS: are inner try/catches necessary?
exported js helpers file
export const foo1 = async () => {
const url = "www.foo.com";
try {
response = await fetch(url, { method: 'POST'});
} catch (e) {
throw new Error(`return another error:${e}`);
}
if (response) {
const responseText = await response.text();
const blob = responseText.toBlob();
return blob;
}
}
main js file
If I import the foo1 function in here and put it in a try/catch:
try {
this.fooData = await foo1();
} catch(e) {
this.error = e
}
can I remove the try/catch from foo1's fetch? Is it now unncessary since I have one in the main function that is invoking foo1?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
