Need help with SL api | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Need help with SL api

https://code.sololearn.com/Wj19CZi7D04s/?ref=app Can I have an example code plz?

17th Apr 2021, 10:30 PM
Hello
Hello - avatar
4 Answers
+ 8
Hello there! :) I changed a bit your code and now it's working :) https://code.sololearn.com/WfDLevapDYdb/?ref=app I added relevant tags where I modified your code. If it's not clear, I can try to explain it more detailed :)
19th Apr 2021, 2:49 PM
Matthew
Matthew - avatar
+ 2
「HAPPY TO HELP」 and Twin Chick 🐣🐣🐣🐤🐤🐤🐥🐥🐥 it's because userId is given a number value on line 6. You can't call includes on a number.
17th Apr 2021, 10:57 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
+ 2
You are trying to assign an integer value to the string variable userId ☺️ It should be: userId = "21344701" You can shorten the code: var userId = prompt("Enter your id (Leave it blank if you want MY id.)") || "21344701";
17th Apr 2021, 11:04 PM
Solo
Solo - avatar
+ 2
Twin Chick 🐣🐣🐣🐤🐤🐤🐥🐥🐥 You might want to do some error handling with this. If I enter a string value in the prompt, there's an uncaught error on line 22. In fact, all the lines below that (apart from window.onload obviously) will fail because you won't have a userDetails property on the data you get back.
17th Apr 2021, 11:24 PM
CamelBeatsSnake
CamelBeatsSnake - avatar