Fetch API in JavaScript

Our program will:

  1. Call the fetch function and give it’s going to give it a single argument which is the path to the resource. In this case it will be a local file.
  2. Deal with the response. This is when we receive the response. This involves the idea of a promise. The response is a stream of data.
  3. Once we receive the data we need it will need to be read. This is where we will complete and grab the data in the response.
  4. Make an <img> element with the data retrieved.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store