This commit is contained in:
Ordis 2023-06-04 02:47:09 +02:00
parent 2d312a97a3
commit dd8438cf26

View File

@ -13,13 +13,14 @@ const inventoryController: RequestHandler = async (request: Request, response: R
console.log(accountId); console.log(accountId);
const inventory = await Inventory.findOne({ accountOwnerId: accountId }); // has the accountOwnerId field to find a corresponding inventory const inventory = await Inventory.findOne({ accountOwnerId: accountId }); // has the accountOwnerId field to find a corresponding inventory
const inventoryJSON = inventory?.toJSON();
if (!inventoryJSON) { if (!inventory) {
response.status(400).json({ error: "inventory was undefined" }); response.status(400).json({ error: "inventory was undefined" });
return; return;
} }
const inventoryJSON = inventory.toJSON();
const inventoreResponse = toInventoryResponse(inventoryJSON); // remove the accountOwnerId for the response const inventoreResponse = toInventoryResponse(inventoryJSON); // remove the accountOwnerId for the response
response.json(inventoreResponse); response.json(inventoreResponse);