FirstHack 2026 — a 36-hour online hackathon built for first-year students.•₹1,00,000 prize pool•22 Oct – 4 Nov•Open to every branch and every stream•Certificate for every team that submits•3 rounds•FirstHack 2026 — a 36-hour online hackathon built for first-year students.•₹1,00,000 prize pool•22 Oct – 4 Nov•Open to every branch and every stream•Certificate for every team that submits•3 rounds•
Ask another server for data, wait for it properly, and show it on your page.
13 min read·Lesson 6 of 6·Pro
What an API is
An API here means a URL that returns data instead of a page. You send a GET request, you get back JSON. No HTML, no styling, just facts.
JSON looks like a JavaScript object written as text:
JavaScript
const text = '{"name":"Ravi","year":2,"subjects":["DS","OS"]}';
const student = JSON.parse(text);
console.log(student.name); // Ravi
console.log(student.subjects[1]); // OS
console.log(JSON.stringify(student));
Rules JSON enforces that JavaScript does not: keys must be in double quotes, strings must use double quotes, no trailing comma, no comments.
fetch returns a promise
The rest of this lesson is Pro
The free lessons of Web Development Basics finish what
they start — read those first if you have not. This one goes further, and it
is part of the paid half.
A pass opens the paid lessons of every course, the mock test papers
and the company-wise series. It ends on its own date; nothing renews by itself.