JSFiddle - React, Tailwind, and code Playground

by maxell4o

TypeScript

async function tokenize() {
  try {
    const data = await Promise.resolve({
      error: 'something'
    });
    if (typeof data === 'object') {
      if (!data.txId) {
				throw new Error(JSON.stringify(data));
      }
			console.log('im here');
      return {
        token: data.txId
      };
    } else {
      throw new Error('Validation error!');
    }
  } catch (e) {
  	console.log('catch',e.message);
  }
}

tokenize();