reactjs app, cannot fetch properly with params on json server

23 Views Asked by At

So, I am building this reactjs app, and I have a json server running on localhost holding my product list array with different objects (products).

The DB looks like this:

    {
    "products": [
        {
        "id":10001,
        "name": "Basics to Advanced in React", 
        "price": 29,
        "in_stock": true
        },
        {
        "id":10045,
        "name": "JavaScript modules", 
        "price": 38,
        "in_stock": true
        },
        {
        "id":10023,
        "name": "ES6 Features", 
        "price": 79,
        "in_stock": false
        },
        {
        "id":10055,
        "name": "Nextjs react", 
        "price": 19,
        "in_stock": false
        },
        {
        "id":10155,
        "name": "JQuery shananigans", 
        "price": 99,
        "in_stock": true
        }
    ]
    
    }

Why, when I change the URL to: http://localhost:8000/products?in_stock=true , it does not return only the products that are in stock? In fact it returns an empty array. I have tried this on postman and it returns me an empty array. Any ideas? Thanks

0

There are 0 best solutions below