4 ms·
Isn't that what node-fetch is for? https://www.npmjs.com/package/node-fetch https://www.npmjs.com/package/node-fetch
by lylejantzi3rd 3y ago
Isn't that what node-fetch is for?
https://www.npmjs.com/package/node-fetch https://www.npmjs.com/package/node-fetch
- runarberg 3y agoThe fetch API is implemented in node and is provided as globals since node 18. So node-fetch is effectivly obsolete at this point. What I’m looking for is a server framework (like express.js) which uses these standards instead of their home made APIs. So instead of: app.use(json()); app.get("/echo", (req, res) { const { message } = req.body; res.append("Content-Type", "application/json"); res.send(JSON.stringify({ message })); }); I could write something like: app.get("/echo", async (request) => { const { message } = await request.json(); const headers = new Headers([[ "Content-Type", "application/json" ]]); return new Response( JSON.stringify({ message }), { headers }, ); });