[Vuejs]-Proper way to catch errors other than network issues in fetch() call

0๐Ÿ‘

โœ…

if you are using async await you could use the classic try...catch...finally

try {
    await fetch(`${this.baseUrl}/wp-json/contact/v1/send`, {
            method: 'POST',
            body: formData
          })

} catch (e) {
    console.error(e);
} finally {
    console.log('We do cleanup here');
}

Leave a comment