0

XmlHttpRequest module

Can i used http request such xhr /axios /fetch or each other ? and how to use it ? bc when i type require("node-fetch") it show no module named "node-fetch"

17th Apr 2021, 7:14 PM
T1mun
T1mun - avatar
1 Antwort
0
You don't have access to a full Node environment on Sololearn. To be able to use a package like "node-fetch", you need to be able to download it first using something like NPM or Yarn. You can't do that on Sololearn. It's the same for "axios". If you had a full Node environment, you'd be able to install any such package. Then your require function would work. You'll find that Node doesn't come with the fetch or XMLHttpRequest you get with bowsers because those are web API ms which are not part of the ECMA script standard. You can use the built-in https module instead. This should work on Sololearn. https://nodejs.dev/learn/making-http-requests-with-nodejs
17th Apr 2021, 7:42 PM
CamelBeatsSnake
CamelBeatsSnake - avatar