Example 1 — append
Multiple values.
JavaScript
const h = new Headers();
h.append("Accept", "text/html");
h.append("Accept", "application/json");
console.log(h.get("Accept"));How It Works
- append adds another value.
Create headers with new Headers(), then set/get/has. Header names are case-insensitive.
const h = new Headers();
h.set("Content-Type", "application/json");
console.log(h.has("content-type"));
console.log(h.get("Content-Type"));Multiple values.
const h = new Headers();
h.append("Accept", "text/html");
h.append("Accept", "application/json");
console.log(h.get("Accept"));CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful