M
M
Mdmitr2020-10-29 17:28:14
JavaScript
Mdmitr, 2020-10-29 17:28:14

How to make an api request in express js?

How can I get data from api in Express js, for example from https://jsonplaceholder.typicode.com/todos/1

I have an api that does not work on the client, I need to get it on the server and send it to the frontend.
How can I do that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DeniSidorenko, 2020-10-29
@Mdmitr

Library Here

var request = require('request');
request('https://jsonplaceholder.typicode.com/todos/1', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) 
  }
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question