JSFiddle - React, Tailwind, and code Playground

by ptitgraig

JavaScript

async function initStore() {
  console.log('init store start');
  await fetch("https://cvouoc.com/echo/html2/", {
      method: "POST",
      body: "html=<a href='#'>hello world</a>"
    }).catch((error) => {
      // should throw "Failed to fetch"
      console.log('throw error:', error);
      throw new Error(error);
    });
  console.log('init store end');
}

function go() {
  try {
    initStore().catch((e) => {
    	// ça vient ici
    	console.log(`erreur initStore bien attrapée ${e}`);
    }) ;
  } catch (e) {
    // ça vient plus ici
    console.log(`erreur initStore attrapée ${e}`);
  }
}

go();