Junior — Middle
Have you worked with REST API in your projects?
sobes.tech AI
Answer from AI
Yes, in several projects I have worked with REST API on Node.js, using the Express framework. REST API allows creating web services that use HTTP requests to interact with clients. I implemented routes to handle GET, POST, PUT, DELETE requests, ensured data validation, and error handling.
Example of a simple REST API on Express:
const express = require('express');
const app = express();
app.use(express.json());
let items = [];
app.get('/items', (req, res) => {
res.json(items);
});
app.post('/items', (req, res) => {
const item = req.body;
items.push(item);
res.status(201).json(item);
});
app.listen(3000, () => {
console.log('Server started on port 3000');
});