+ 8
Wikipedia API node.js
My node.js code fetching Wikipedia data doesn’t work!!! https://code.sololearn.com/ct3844Bw1ppt/?ref=app
19 Antworten
+ 4
Galaxy-Coding (CodeWarrior) This is the code up to now:
https://code.sololearn.com/cVxoOVh9KL7c/?ref=app
It needs improvements but it's working.
+ 9
Ugwu Chiagozie Stanley
Abhay
Pasindu Dewmith Kawshalya Hettige
Kevin ★
The code was based off of:
https://code.sololearn.com/WibuIX2P5oRV/?ref=app
Please help me. I really want the code to work.
+ 8
Kevin ★ The code then stiil turns out bad and I want JSON elements to be displayed like this:
console.log("Title:${json.title}\n${json.description}\n${json.extract}");
+ 7
Kevin ★ sorry that’s too complicated for me. I guess i wil lhave to start another project
+ 6
Kevin ★ I want it to work on node.js. How can I do that?
+ 6
Kevin ★ Perfect. Thank you. What do u mean by improvement?
+ 6
Kevin ★
I added input, still doesn’t work please help.
https://www.sololearn.com/discuss/2476988/?ref=app
https://code.sololearn.com/ct3844Bw1ppt/?ref=app
+ 5
The code does work. Try using this URL:
https://en.wikipedia.org/api/rest_v1/page/summary/Wikipedia
As I said before the correct template literals syntax uses backtickts: ``
https://www.sololearn.com/learn/JavaScript/2969/
+ 5
something is wrong in the api link as i when copy-paste the link in browser, it shows the same message
+ 5
though i had not been in this thread to solve your problem, i modified the code to show what was going behind the scenes
https://code.sololearn.com/czAeVqS3yHrQ/?ref=app
+ 4
Galaxy-Coding There are many ways to fetch with Node. Example using https module:
https://code.sololearn.com/cvh4pqZ7K4Zf/?ref=app
+ 4
why doesnt it work?!!
Kevin ★
+ 3
XMLHttpRequest is a web API available on browsers. Run your code in web playground.
Use template literals `${to allow string interpolation } `
+ 3
Abhay Try Tiger 🙂. Btw this is my first xp with Wikipedia Api, learning new stuff.
Galaxy-Coding (CodeWarrior) But why?
+ 3
Galaxy-Coding (CodeWarrior) Line 45: fetch(endpoint+userinput)
userinput is an empty string. You haven't update it. Just use the recieved line to fetch:
fetch(endpoint+input)
You can find "input" at line 45 in the callback to readline.on("line")
+ 3
Ok, so essentially, you need to replace whitespaces with underscores, like this:
Hurricane Katrina
To
Hurricane_Katrina
+ 2
When I add tiger instead of Wikipedia ,it throws error ,any idea why so Kevin ★
+ 2
Well that worked ,ty but in browser "tiger" works well tho!
well that tiger was automatically converted to Tiger after I checked the link
something is happening in between when request is made from using a browser and fetch but no idea what is it!
+ 2
The code is okay, you are fetching from the wrong url