+ 8

Wikipedia API node.js

My node.js code fetching Wikipedia data doesn’t work!!! https://code.sololearn.com/ct3844Bw1ppt/?ref=app

24th Sep 2020, 8:44 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar
19 Respostas
+ 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.
27th Sep 2020, 6:29 AM
Kevin ★
+ 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.
25th Sep 2020, 12:42 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar
+ 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}");
24th Sep 2020, 9:10 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar
+ 7
Kevin ★ sorry that’s too complicated for me. I guess i wil lhave to start another project
24th Sep 2020, 10:23 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar
+ 6
Kevin ★ I want it to work on node.js. How can I do that?
24th Sep 2020, 9:00 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar
+ 6
Kevin ★ Perfect. Thank you. What do u mean by improvement?
27th Sep 2020, 3:05 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar
27th Sep 2020, 8:53 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar
+ 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/
24th Sep 2020, 10:21 PM
Kevin ★
+ 5
something is wrong in the api link as i when copy-paste the link in browser, it shows the same message
25th Sep 2020, 5:04 AM
Bot
Bot - avatar
+ 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
28th Sep 2020, 2:58 AM
Bot
Bot - avatar
+ 4
Galaxy-Coding There are many ways to fetch with Node. Example using https module: https://code.sololearn.com/cvh4pqZ7K4Zf/?ref=app
24th Sep 2020, 9:04 PM
Kevin ★
+ 4
why doesnt it work?!! Kevin ★
29th Sep 2020, 11:15 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar
+ 3
XMLHttpRequest is a web API available on browsers. Run your code in web playground. Use template literals `${to allow string interpolation } `
24th Sep 2020, 8:58 PM
Kevin ★
+ 3
Abhay Try Tiger 🙂. Btw this is my first xp with Wikipedia Api, learning new stuff. Galaxy-Coding (CodeWarrior) But why?
24th Sep 2020, 10:33 PM
Kevin ★
+ 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")
27th Sep 2020, 9:09 PM
Kevin ★
+ 3
Ok, so essentially, you need to replace whitespaces with underscores, like this: Hurricane Katrina To Hurricane_Katrina
28th Sep 2020, 11:46 PM
PresidentOfYes12
PresidentOfYes12 - avatar
+ 2
When I add tiger instead of Wikipedia ,it throws error ,any idea why so Kevin ★
24th Sep 2020, 10:28 PM
Abhay
Abhay - avatar
+ 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!
24th Sep 2020, 10:45 PM
Abhay
Abhay - avatar
+ 2
The code is okay, you are fetching from the wrong url
25th Sep 2020, 10:15 AM
Ugwu Chiagozie Stanley
Ugwu Chiagozie Stanley - avatar