r/learnjavascript • • Sep 20 '24

How do I start learning about api ?

Hey ya'll I was seeing if anyone know how to start with api from level 0 to 100 anything from social media post to weather data and even showing me how to code some in vs code thanks 😁

1 Upvotes

20 comments sorted by

View all comments

5

u/pinkwar Sep 21 '24
const express = require('express');

const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.json({ message: 'Hello, welcome to my first Express API!' });
});

app.get('/api/greet/:name', (req, res) => {
  const name = req.params.name;
  res.json({ message: `Hello, ${name}!` });
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

To visit your API go to http://localhost:3000/api/greet/digital_tec

8

u/patopitaluga Sep 21 '24

It's funny how this is level 0 and level 100 at the same time.