Coding Exercise: Make a GET Request with node-fetch

Use node-fetch to make a GET request.

Let’s complete the getTriviaQuestion() function code in the provided code snippet.

Challenge: Use node-fetch to make a GET request

The function we complete should do the following:

  • Make a GET request to API_URL.
  • Return the API data if the request is successful.
  • Log an error to the console if the request is unsuccessful.

Make sure to use the try/catch pattern when implementing the function.

Get hands-on with 1200+ tech skills courses.