Thuta Learning
ExercisesWeb Developmentintermediate

Practice Set 1: Request Fundamentals

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Work through Practice Set 1: Request Fundamentals on your own
  • Practice the skills you've already learned until they're solid
  • Get comfortable finding bugs, fixing them, and checking your own work

Take a moment to think about this

This Practice Set isn't a new lesson — it's meant to put the concepts you already learned in Auth Overview, HTTP Methods, and Response Shape to the test by actually writing requests. It mainly checks whether you can handle the case sensitivity of header names, tell Bearer Token and API Key apart, and pull individual fields out of a JSON response. Each task should take about 5 minutes, and all you need is a code editor and a terminal.

Exercises

Task 1: fetch GET /v1/users with an Authorization: Bearer <token> header attached, and console.log the response.status. Task 2: rewrite the request above using an X-API-Key: <key> header instead of a Bearer Token, call it, and think about how the header format differs. Task 3: take the sample JSON response below { "data": [{ "id": "u_1", "name": "Alice", "email": "alice@example.com" }] }, store it in a variable, then pull out and print just the email field of the first user.

Code Example

javascript
// Task 1
async function task1() {
  const res = await fetch('https://api.example.com/v1/users', {
    headers: { Authorization: 'Bearer YOUR_TOKEN' },
  });
  console.log('status:', res.status);
}

// Task 2 - TODO: X-API-Key header နဲ့ ပြန်ရေးပါ
async function task2() {
  // const res = await fetch(..., { headers: { 'X-API-Key': 'YOUR_KEY' } });
}

// Task 3
const sample = {
  data: [{ id: 'u_1', name: 'Alice', email: 'alice@example.com' }],
};
const firstEmail = sample.data[0].email; // TODO: verify
console.log(firstEmail);
You should see
Task 1 should show status: 200 (or 401) in your terminal, and Task 3 should print out just the single string alice@example.com.

5-Minute Try-It

Using your own Postman or a curl command, actually run Task 1's request within 5 minutes and check the Header tab to see whether Authorization is there or not.

A Quick Word of Caution

Stick to dummy values while practicing, so you never accidentally put a real token or key into public code (GitHub, screenshots, etc.).

Easy traps

  • Writing the header name as lowercase authorization by mistake, which some request libraries won't recognize
  • Trying to pull a field straight out of response.json() without awaiting it first, and ending up with undefined

Now Try It Yourself

Using your own Postman or a curl command, actually run Task 1's request within 5 minutes and check the Header tab to see whether Authorization is there or not.

You'll know it worked when: Task 1 should show status: 200 (or 401) in your terminal, and Task 3 should print out just the single string alice@example.com.

Practice Set 1: Request Fundamentals | Thuta Learning