Node.js and REST API Interview Questions: Methods, Status Codes, JWT

LAB 19 The Interview Lab · Full-Stack Developer

Node.js and REST API questions, made simple

Learn the HTTP methods, status codes, middleware, REST vs GraphQL and JWT basics that most backend and full-stack interviews ask, with clear model answers.

⏱ 10 min🎯 Freshers & developers🧪 4 hands-on drills
Your lab progress0 of 4 drills done
Spot itDecodeBuildTest

If you apply for a full-stack or backend role, you will almost surely be asked how a server talks to a browser or a mobile app. Node.js with Express is a very common way to build this, so interviewers use it to test your basics.

After this lab, you will be able to explain HTTP methods and status codes, describe how middleware works in Express, compare REST with GraphQL, and explain JWT login in simple words.

The big idea: define, detail, prove

A strong technical answer has three parts. Use them for any API question.

~15s
FRAME 1
Define
Give a short, correct definition in one line.
~20s
FRAME 2
Detail
Add the key rule, difference or status code.
~20s
FRAME 3
Prove
Show where you used it in a real project.
Define it, detail it, prove it. Three steps for any technical question.
Drill 1 · Spot it

Spot the difference

Question: “What is the difference between PUT and PATCH? What status code do you send after creating a user?” Switch between the two answers.

PUT and PATCH are both used to update data, so they are almost the same. Honestly I use POST for everything because it always works. After creating the user I return 200 because that means success. Status codes are not that important as long as the frontend gets the data. In my project I sent errors with 200 also, with a message field.
✕ Mixes up the methods
✕ Wrong status code for create
✕ Hides errors behind 200
Drill 2 · Decode

Quick concept check

Tap each card to flip it.

Key concepts, explained simply

An everyday picture first, then the correct technical answer.

RESTThink of a library where every book has a fixed shelf address. In REST, each resource, like /users/42, has its own URL, and you act on it with standard HTTP methods. Each request carries everything needed, so the server keeps no session memory. This is called stateless.
HTTP methodsGET reads, POST creates, PUT replaces, PATCH updates part, DELETE removes. GET is safe because it changes nothing. GET, PUT and DELETE are idempotent: repeating them gives the same end result. POST is not.
Status codes2xx means success: 200 OK, 201 Created, 204 No Content. 4xx means the client made a mistake: 400 Bad Request, 401, 403, 404 Not Found, 409 Conflict. 5xx means the server failed: 500 Internal Server Error.
Middleware in ExpressThink of airport security checks, one after another. Middleware runs in the order you add it with app.use(). Common uses are reading JSON, logging and checking login. Error-handling middleware takes four arguments: err, req, res, next.
REST vs GraphQLREST is like a fixed thali; GraphQL is like ordering only the dishes you want. REST has many URLs, each with a fixed response shape. GraphQL usually has one endpoint, and the client asks for exactly the fields it needs. It avoids extra data but needs more setup.
JWT basicsA JSON Web Token is like a signed gate pass. It has three parts joined by dots: header, payload and signature. The server signs it at login and checks the signature on later requests. The payload is only encoded, not encrypted, so never put passwords in it.
const express = require('express');
const app = express();
app.use(express.json()); // middleware: reads the JSON body

app.post('/users', (req, res) => {
  if (!req.body.name) return res.status(400).json({ error: 'name is required' });
  res.status(201).json({ id: 1, name: req.body.name });
});

// error handler: four arguments
app.use((err, req, res, next) => res.status(500).json({ error: 'Something went wrong' }));
app.listen(3000);
💡 Always say the status code number and its name together, like “404 Not Found”. It shows you know the standard, not just the idea.
Drill 3 · Build

Build your API project answer

Fill the blanks. Your answer writes itself on the right.

Your answer
Start typing on the left and your answer will appear here.
⏱ ~0 seconds spoken0 words

Three model answers you can adapt

Three common questions. Each answer follows define, detail, prove.

“When a request reaches an Express app, the middleware runs in the order I added it. For example, express.json() first reads the JSON body, and then my auth middleware checks the token. If all is fine, the matching route handler runs, talks to the database and sends a response with a status code. In my college project, a missing token stopped the request early with 401 Unauthorized, so the route never ran.”

Four mistakes that cost you the round

Returning 200 for everythingIf errors also return 200, the frontend cannot tell success from failure. Use 4xx for client errors and 5xx for server errors.
Saying a JWT is encryptedA normal JWT is signed, not encrypted. Anyone can decode the payload, so never store passwords or secrets in it.
Forgetting next() in middlewareIf middleware neither sends a response nor calls next(), the request hangs. Mentioning this shows real hands-on experience.
Calling any JSON API “REST”REST means resources with clear URLs, correct HTTP methods and stateless requests. One POST route that does everything is not RESTful.
Drill 4 · Test

Test yourself

Question 1 of 5

0:00

Rehearse before the real thing

Press start and answer one question out loud, like “What is middleware?”. Use define, detail, prove and try to finish within 90 seconds.

Interview Lab · 19
Node.js + REST API basics
  1. 1POST creates, PATCH updates
  2. 2401 = log in, 403 = not allowed
  3. 3Middleware: next() or respond
  4. ★JWT is signed, not encrypted
worldremotejobs.com@keshav_consults

Screenshot it. Save it. Share it.

Keep this card on your phone and look at it five minutes before your interview.

Share on WhatsApp
Next in the lab
Lab 20 · Group discussion rounds
Open lab →

Quick answers

Do I need to learn Express for Node.js interviews?

Most Node.js backend jobs use a framework, and Express is the usual one to learn first. Knowing its routing and middleware also makes it easier to pick up others like Fastify or NestJS.

What is the difference between authentication and authorization?

Authentication checks who you are, like logging in. Authorization checks what you are allowed to do, like opening admin pages. Failing the first usually means 401; failing the second means 403.

Is GraphQL replacing REST?

No. Both are widely used. REST is simple and fits most create, read, update and delete APIs. GraphQL helps when many clients need different shapes of data. Many companies use both.

How should I prepare for a live API coding round?

Practise building a small CRUD API with Express in under 30 minutes: routes, input checks, correct status codes and an error handler. Test it with Postman or curl and explain your choices out loud.

More remote jobs

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *