I have a collection in a JSON file, when I access it by http://localhost:5000/product/ I see it, but when I try to get a specific product from it, like http://localhost:5000/product/1 I see nothing but [], what could be a possible solution to this?
I expect the output of http://localhost:5000/product/1 to be
{
"Id": 1,
"name": "Milk",
"Quantity": 100,
"Unit_coast": 2000
}
2
Answers
create get productById new API end point
the logic :
jsut note that the filter method will always return an array – ieither use an index or use find()
as per Berlin Johns. M answer – but with an index on the return
or use find to return the indidivudal item
and if you want to use more current arrow function