15Dkatz / official_joke_api

Official Joke API!
https://davidtkatz.com
MIT License
842 stars 348 forks source link

endpoint jokes/:type/random wrong type of response #48

Closed fdsdev90 closed 2 years ago

fdsdev90 commented 4 years ago

Good morning, as I tested your api with springboot, I've seen that using this call

https://official-joke-api.appspot.com/random_joke

I've this response: { "id":289, "type":"general", "setup":"What’s brown and sounds like a bell?", "punchline":"Dung!" }

but, when I use a category instead, I've in output an array

https://official-joke-api.appspot.com/jokes/programming/random

[ {"id":379,"type":"programming","setup":"A programmer puts two glasses on his bedside table before going to sleep.","punchline":"A full one, in case he gets thirsty, and an empty one, in case he doesn’t."} ]

I think when using the endpoint jokes/:type/random the response should be an object and not an array.

navinor commented 4 years ago

what do you mean by "object"? Like a dictionary?

chrispine commented 4 years ago

Since they were talking about the JSON response, they probably meant a JSON object.

navinor commented 4 years ago

ok

15Dkatz commented 2 years ago

Unfortunately, this design is intentional to support a coding course I created a while back. If anyone is reading this, I recommend creating a condition in your client-side code that recognizes this programming/random endpoint, and grabs the first item from the array.