I am trying to console the data from "https://pokeapi.co/api/v2/pokemon" using HTTPS GET request but the console gives the following error: Error I am getting while making the GET request
This is my code: Code
I make the use of HTTPS Get request method to get the data and was expecting to get the JSON but couldn't.
res.on('data')
provides a stream
of data
. This means that it sends parts of the request one at a time. When using the https lib you could add the responses
one by one to a string and then parsing everything in res.on('end')
. I would suggest though using an easier HTTP
library, for instance I really like using axios
. If you cannot figure out how to use res.on('data'
and res.on('end'
let me know and I'll type up an example for your situation.
Found the answer here: How to get data out of a Node.js http get request
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.