Animechan-API / animechan

A REST API for anime quotes
https://animechan.io
Mozilla Public License 2.0
1.31k stars 56 forks source link

No error when getting an invalid title query #99

Closed R1nge closed 8 months ago

R1nge commented 9 months ago

When trying to access an invalid character name an error is returned https://animechan.xyz/api/random/character?name=saitamaA Will return a response with an error "No related quotes found!" But, it returns nothing with an invalid title query https://animechan.xyz/api/random/anime?title=narutoO Will return nothing

R1nge commented 9 months ago

I have found the problem in https://github.com/rocktimsaikia/animechan/blob/main/server/controller/index.ts

Basically, getRandomQuoteByAnime is missing this check

if (isEmpty(randomQuote)) {
    return res.status(StatusCodes.NOT_FOUND).json({
        error: 'No related quotes found!',
    });
}