0

db.json example:

{
"articles":[{"art_id":1,"cat_id":1,"article":"Communication Device","description":"Small communication device in the shape of a pencil.","price":49.9900,"instock":25}],
"customers":[{"cust_id":1,"lastname":"De Vlieger","firstname":"Mehdi","city":"Bruges","birthdate":"1990-05-30"}]
}

Request example:

PUT: http://localhost:3000/articles?article=Communication%20Device

BODY: To change the price

{
        "art_id": 1,
        "cat_id": 1,
        "article": "Communication Device",
        "description": "Small communication device in the shape of a pencil.",
        "price": 39.99,
        "instock": 25
}

RESPONSE: 404 Not Found

3
  • Can you add the api code that accepts this? Commented Jan 18, 2023 at 15:42
  • It is made withe JSON-server so just the main function that takse the json file and truns it into a REST api Commented Jan 22, 2023 at 17:48
  • json-server requires you to be using the keyword "id" rather than "art_id", PUT requests also don't do anything unless they are PUT localhost:3000/articles/1 Commented Jan 25, 2023 at 12:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.