JavaScript
http
JavaScript HTTP GET: Fetch API Basics
Fetch API GET request tutorial
0 views
Updated 11/17/2025
Ready to test this code?
Load this example into the app
Code Example
Copy and run
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then(r => { if(!r.ok) throw new Error('HTTP '+r.status); return r.json(); })
.then(console.log)
.catch(console.error)Overview
Overview
This example shows how to fetch JSON over HTTP using the native fetch API.
Best Practices
- Handle non-200 status codes.
- Parse JSON safely.
- Add timeouts or abort controllers for long requests.
Related Topics
javascript
http
fetch
api

