JSFiddle - React, Tailwind, and code Playground

by navinleon

JavaScript

// Create a method to make API call
// Handle success and failure
// Existing API calls, then skip
// 2 API cal should be made
// 3 console log


const makeApiCall = (callback) => {

fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(response => response.json())
  .then(json => callback(json))

}

makeApiCall(() => { 
	console.log('hi'); 
});
makeApiCall(() => { 
	console.log('hello'); 
});
setTimeout(makeApiCall(() => 'make call again'), 5000);