The Starter API
The app is handed over, so the work is the data. Learn the JavaScript the starter uses (variables, functions, modules, async and await, try and catch), then tour the Express API for a pet adoption site: its routes, requests and responses.
Updated
The JavaScript You Need
- The JavaScript You Need: Variables, Functions and Modules (Apprentice): The pet adoption API in this module is written in JavaScript, and this lesson teaches the part of it you'll change, starting from the objects you already know from mongosh, then const and let, functions with return and template literals, arrow functions with filter and find, and import and export between files.
- Waiting for the Database: async, await and try/catch (Apprentice): A database takes a moment to answer, so code that asks it gets a promise instead of the answer, and this lesson shows how await waits for the answer inside an async function, how try and catch handle a database that fails, and what happens when an await is missing.
The Express Starter
- A Tour of the Express Starter: Routes, Requests and Responses (Apprentice): The Maple Street Pet Adoption Center's API is handed over, built with Express, and this lesson runs it and tours it, from npm start and its routes to req.params, req.query and req.body, res.json and status codes, ending at data/pets.js, the one file the database code goes in.
Exercise: Pet API Warm-Up
- Exercise: Pet API Warm-Up (Apprentice): Finish the three async functions in the pet adoption API's data file, listing pets by species, finding one pet by its id and adding a pet, so its routes work, and let the Supertest tests check every answer.