15Dkatz/official_joke_api

endpoint jokes/:type/random wrong type of response

fdsdev90 opened this issue · 4 comments

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.

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

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

ok

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.