HTTP headers are key-value pairs that travel alongside a request or response — they carry metadata like content type, auth tokens, and custom information.
In `fetch`, you set request headers in the options object:
```javascript
const response = await fetch(url, {
headers: {
'Authorization': 'Token abc123',
'X-Custom-Header': 'my-value',
},
});
```
You can also use the `Headers` class for a more structured approach:
```javascript
const headers = new Headers();
headers.set('Authorization', 'Token abc123');
headers.set('X-Request-ID', '42');
const response = await fetch(url, { headers });
```
The `/api/echo/` endpoint reflects back exactly what you sent — it's useful for verifying that headers arrive as expected:
```javascript
const response = await fetch('https://apilearn.tukas.dev/api/echo/', {
headers: { 'X-Custom-Header': 'hello' },
});
const data = await response.json();
// data.headers contains the headers the server received
console.log(data.headers['X-Custom-Header']); // "hello"
```
The echo endpoint returns:
```javascript
{
method: "GET",
headers: { /* all request headers */ },
body: null,
query_params: {}
}
```
Send a GET request to `/api/echo/` with a custom header `X-My-Name: YourName`. Print the value of that header from the echo response.
const BASE_URL = 'https://apilearn.tukas.dev';
async function main() {
// GET /api/echo/ with X-My-Name header
// print the echoed header value
}
main();
Send GET `/api/echo/` with three headers: `X-App: my-app`, `X-Version: 1.0`, and `X-Request-ID: 42`. Print the full `headers` object from the response.
Send GET `/api/echo/?color=blue&size=large`. Print the method and the `query_params` object from the response.
const BASE_URL = 'https://apilearn.tukas.dev';
async function main() {
// GET /api/echo/ with two query params
// print method and query_params
}
main();
Send POST to `/api/echo/` with a JSON body `{name: "test"}` and the `Content-Type: application/json` header. Print the echoed `Content-Type` header and the `body` field.
const BASE_URL = 'https://apilearn.tukas.dev';
async function main() {
// POST /api/echo/ with JSON body and Content-Type header
// print the content-type header and body from response
}
main();
We use necessary cookies to run the site. With your permission, we can also save your site preferences and use analytics and advertising cookies to understand usage and support the project.
Open tools in tabs.Exercises, IDE tools, and trainers stay available as site tabs.
Switch without losing context.Move between explanations, code, and utilities while keeping your place.
Use the sidebar as your map.The left panels hold navigation, settings, files, libraries, and tool controls.
PythonJavaScriptSQLite
One IDE, three practical modes
Python in the browser.Run small scripts, try libraries, and practice API requests without installing anything.
JavaScript for quick experiments.Test browser-friendly code and compare ideas next to your learning materials.
SQLite for data practice.Open the database explorer to inspect tables, write queries, and learn SQL workflows locally.
TopicIDE
Work side by side with split tabs
Keep instructions visible.Open an exercise or reference page beside the IDE instead of jumping back and forth.
Compare tools while you learn.Place regex checks, explanations, and code experiments next to each other when the task needs it.
Close the split when you are done.The workspace returns to a single focused tab, and your open site tabs remain available.
Code Typing Trainer
Or plain text
This trainer is designed for a physical keyboard.Open this section on a laptop or desktop with a wide screen. Touch typing practice will not work correctly on a phone.
Speed: 0 chars/min
0 words/min
Best speed (60s): 0 chars/min
0 words/min
Errors: 0
Total time: 0.0 s
To practice touch typing, avoid looking at your physical keyboard.