DEV Community

Cover image for CRUD with JavaScript Fetch and the Platzi Fake Store API
Ahmed Niazy
Ahmed Niazy

Posted on

CRUD with JavaScript Fetch and the Platzi Fake Store API

Image description
CRUD stands for Create, Read, Update, and Delete — the four basic operations used when interacting with data in any application.

With JavaScript and the Fetch API, you can communicate with a backend server (like the Platzi Fake Store API) to perform CRUD operations on product data.

  1. Read You can retrieve all products or a specific product by ID or slug:

All Products: GET https://api.escuelajs.co/api/v1/products

By ID: GET https://api.escuelajs.co/api/v1/products/4

By Slug: GET https://api.escuelajs.co/api/v1/products/slug/handmade-fresh-table

  1. Create To add a new product:

POST https://api.escuelajs.co/api/v1/products

Include product data in the request body as JSON.

  1. Update To modify an existing product:

PUT https://api.escuelajs.co/api/v1/products/1

Pass updated fields in the request body.

  1. Delete To remove a product:

DELETE https://api.escuelajs.co/api/v1/products/1

📘 You can read the full guide attached above for a detailed explanation in English with full code examples.
Here

Top comments (4)

Collapse
 
nevodavid profile image
Nevo David

pretty cool walk-through tbh, makes me wanna build something simple again - you ever run into headaches hooking up apis like this or does it just click after a while?

Collapse
 
ahmed_niazy profile image
Ahmed Niazy

Oh for sure, had my fair share of headaches 😅 but yeah, after a while it kinda just starts to click. Every new API teaches you something.

Collapse
 
nathan_tarbert profile image
Nathan Tarbert

pretty cool, honestly seeing it broken down like this always makes me want to try building stuff myself
you ever mess up a big data call and have to untangle everything afterwards?

Collapse
 
ahmed_niazy profile image
Ahmed Niazy

Oh definitely 😅 messed up more than a few — sometimes one wrong assumption and you’re digging through layers of nested data trying to figure out what broke. But that’s how you really learn, I guess.

Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more