Hi @mikey,
I’ve managed to get requests to pass successfully, however it seems like my keg isnt actually being updated on the taplist server side. Here is the code
const Auth = require("../models/auth");
const servedController = async (req, res) => {
try {
const { currentTapNumber, servedAmount } = req.body;
const parsedServedAmount = parseInt(servedAmount);
console.log(parsedServedAmount);
console.log(currentTapNumber);
const details = await Auth.find();
const venue = details[0].venue;
const auth_token = details[0].auth_token;
const response = await fetch(
`https://api.taplist.io/api/v1/venues/${venue}/taps/${currentTapNumber}/current-keg`,
{
method: "PATCH",
headers: { Authorization: `Token ${auth_token}` },
body: JSON.stringify({
add_served_volume_ml: parsedServedAmount,
}),
}
);
const data = await response.json();
console.log("keg volume updated");
res.status(200).json(data);
} catch (err) {
console.error("Error occurred while fetching taps:", err);
res.status(500).json({
error: `An error occurred while fetching taps: ${err.message}`,
});
}
};
module.exports = servedController;
if I manually set currentTapNumber to 1 and parsedServedAmount to 1500, nothing gets uodated. Can you spot what I’m doing wrong?
Thanks
EDIT: Spotted it, wasn’t defining the content as a json