Query GET
Filter a list with ?userId=… on the URL (light intro; Phase 15 goes deeper).
Query strings sit after ? in the URL. Servers use them to
filter or paginate. Here: GET posts for one user via
?userId=1. Phase 15 covers building these with
URLSearchParams.
URL appears here.
Important JavaScript
const url =
"https://jsonplaceholder.typicode.com/posts?userId=" + userId;
const response = await fetch(url);
if (!response.ok) {
throw new Error("HTTP " + response.status);
}
const posts = await response.json();