Skip to content
Discussion options

You must be logged in to vote
  1. Run the Server
    node server.js

Then open:

http://localhost:3000/users

Your Node server connects to the API and returns the data.

  1. Alternative Using Native fetch (Node 18+)
    const express = require("express");

const app = express();

app.get("/posts", async (req, res) => {
const response = await fetch("https://jsonplaceholder.typicode.com/posts");
const data = await response.json();
res.json(data);
});

app.listen(3000);

✅ Flow:

Client → server.js → External API → server.js → Client

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Sengwamana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants