Skip to content

Instantly share code, notes, and snippets.

/*
This program simulates the async/await pattern in javascript.
The fetchData function simulates an async call, the corountine
function is used to initialize a generator (genObj) that is passed
as an argument. It then immediately invokes the recursive function
(run), which handles processing the generator until done:true.
It does this by using the value (promise obj) it receieves from calling
next() on the genObj. Once the value is resolved, it is passed to the run
function as an argument (result), and that argument is passed to the next()
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { withRouter } from 'react-router-dom';
import DemoHeader from './DemoHeader';
import SelectFileHeader from './SelectFileHeader';
import SelectFileInput from './SelectFileInput';
import DemoSearchHeader from './DemoSearchHeader';
import DemoSearch from './DemoSearch';
import ResultCard from './ResultCard';