I am having trouble updating the objects in my array and I need to be able to call them in Postman with a new value attached to the item I'm referencing. This is an assignment that is due today, so please help me.
Check out this screenshot from Postman
const express = require("express");
const {emitWarning} = require("process");
// Setting up Express
const app = express()
// Defining port number 8081
const PORT = 8081;
// Listening on designated port
app.listen(PORT, () => console.log("Server is listening on port 8080"))
//Task B
// Creating an array with categories and quantities
var livestock = [
{id:0, category: 'Cows', quantity: 50 },
{id:1, category: 'Dogs', quantity: 1 },
{id:2, category: 'Pigs', quantity: 100 },
{id: 3, category: 'Sheep', quantity: 20 },
];
app.put('/update_livestock/:category/:quantity', (req, res)=> {
if (req.params.category in livestock){
livestock[req.params.category] = req.params.quantity;
res.json(livestock);
} else{
res.sendStatus(404)
}
});