[SOLVED] Wikipedia api arrays response

[SOLVED] Wikipedia api arrays response
0

#1

Hello everyone,
i’m working on my Wikipedia Viewer and I don’t understand why when I search words like “ca”,“cia”,“er”,“qw” and so on, the first result element is the closest result, without paragraph. This is my codepen, sorry for background-colors but i’m trying to understand layout and with colours is simple.


#2

You need to start i at 1 instead of zero.


#3

Your solution don’t works.


#4

Originally I thought you were returning your search value into your array which is why I said to start it one step later. However, now I see that’s not what is happening; “ca” doesn’t return a paragraph because there is no paragraph to return. Try looking up ca on Wikipedia page, you’ll get some kind of disambiguation page. I think that is why you aren’t getting a paragraph.

Hey try taking the encodeURIComponent out of line 4 and just store the plain “keyword” value into searchKeys. I forked your code pe,n left i at 0 and took the encoding out and now it’s only giving me the results with paragraphs. @stefalber


#5

I can’t see your forks :confused: maybe I wrong something because my code still returns me results without paragraph. :frowning:


#6

I wasn’t linking my forks. All you have to do is remove the word on the line I specified. It was an anonymous fork so it didn’t get saved.
image

I’ve done it again here’s the screenshot @stefalber let me know if it works for you.


#7

Still doesn’t work. Maybe I have to change my request.


#8

That’s weird because I edited your forked code pen. That picture is surrounded by the rest of your code I just only wanted to screenshot the part that was being changed and it worked for me. Can you screenshot your code and the results of the search?


#9

free thias is my code and my request.


#10

You haven’t removed the encodeURIComponent in this picture. Can you remove it so you searchKeys variable looks like the picture I posted then search for “ca” and let me know if it stops referencing the one without paragraphs?


#11

It doesn’t stop it. It’s this codepen.


#12

That is incredibly frustrating. I’ll fork it again and try something else.


#13

Obviously, something I did the first time was wrong and accidentally produced the right result. I think what the problem is you want to not return any results that are going to lead to a disambiguation page (the titles with no paragraphs). So this code sets up a condition that only adds the result that contains a paragraph to the page. Hopefully, this is the intended behaviour you desire.


#14

That’s works well. Thank you for the time spent on me. :slight_smile: