PlatziLabs / fake-api-backend

Fake Store API for your e-commerce or shopping website prototype.
39 stars 23 forks source link

in response list of images is badly formated #26

Closed denimsahu closed 7 months ago

denimsahu commented 8 months ago

Describe the bug when filtered category by id 1 that is Clothes category it's response data return badly formatted images list "images": [ "[\"https://i.imgur.com/QkIa5tT.jpeg\"", "\"https://i.imgur.com/jb5Yu0h.jpeg\"", "\"https://i.imgur.com/UlxxXyG.jpeg\"]" ],

Expected behavior a few days ago images list was alright something like this "images":["https://i.imgur.com/QkIa5tT.jpeg","https://i.imgur.com/jb5Yu0h.jpeg","https://i.imgur.com/UlxxXyG.jpeg"],"

ixtk commented 8 months ago

Looks like it doesn't parse JSON correctly on the server side when storing them. A temporary workaround would be to do

product.images[0].startsWith("[") ? JSON.parse(product.images[0]) : product.images[0]

when displaying any single image on the frontend