Toolpuffin

    Loading...

    Up and down to choose, Enter to open, Esc to close.

    A small course in 8 short lessons on using web APIs from JavaScript. You learn what a request and a response are, how to send a request with fetch, how to read the JSON of the answer, how async and await work, how to add parameters to an address, why you should check the status of a response, how to send data with POST and how to handle errors. The address api.example.com in the lessons is made up, no request is sent and your code is not run: the course checks that your answer contains what the task asks for. A typing mistake in your code is not detected. Your code stays in your browser and your progress is remembered there.

    Features

    • 8 short lessons, from a first request to error handling
    • Check my answer, a hint and the model answer for every lesson
    • Made-up address: nothing is sent anywhere
    • Your progress is remembered in this browser

    How to use Learn to Use APIs

    1. Read the lesson and the task.
    2. Write your code in the editor.
    3. Press Check my answer. Use the hint or the answer if you are stuck.
    4. Go to the next lesson.

    Frequently asked questions

    Does this course send real requests?

    No. The address api.example.com is made up and your code is not run. The course uses patterns to check that your code contains what the task asks for. A typing mistake is not detected, so try your code in a real project or in the console of your browser too.

    Do I need to know JavaScript first?

    It helps. The lessons use plain JavaScript, such as constants, functions and if. If that is new, do our Learn JavaScript course first. The Learn JSON course explains the data format that most APIs use.

    Why does fetch not fail on a 404 or a 500?

    A fetch promise only fails when the network fails. A response with a status such as 404 or 500 still arrives as a normal response, so you check response.ok yourself, which is true for the status codes 200 to 299.

    Is my code saved?

    Only which lessons you finished is saved, in this browser. The code you type is not stored or sent anywhere.

    Guides

    Related tools