2xx SuccessCommonly usedRFC 9110
200OK
Request succeeded.
What it means
The most common HTTP response. The request succeeded and the server returned the requested data. The meaning of "success" depends on the HTTP method: GET returns the resource, POST returns the result of the action, PUT/PATCH returns the updated resource.
When to use it
- ✓GET request successfully returned data
- ✓POST action completed and returned a result
- ✓PUT/PATCH update was successful
- ✓DELETE was successful (if returning a body)
Code Examples
Express — GET request
javascript
app.get('/users/:id', async (req, res) => {
const user = await db.users.findById(req.params.id);
res.status(200).json(user);
// or just: res.json(user) — 200 is the default
});Next.js API Route
typescript
export async function GET(req: Request) {
const data = await fetchData();
return Response.json(data, { status: 200 });
}