Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// GET request — read JSON response const res = await fetch("https://api.example.com/users/1"); const user = await res.json(); // Parses JSON automatically // POST request — send JSON body const res2 = await fetch("https://api.example.com/users", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: "Bob", email: "bob@example.com" }), }); const created = await res2.json();
Result
Open