Fix bug in return from addNewNode

- Return the function to get a node from the ID since the add new doesn't return node rows
- Update the controller to send the correct key from the updated object
This commit is contained in:
Logan Cusano
2023-06-18 19:13:03 -04:00
parent 7a040a8e97
commit 878e64fa42
2 changed files with 3 additions and 3 deletions

View File

@@ -38,9 +38,9 @@ exports.newNode = async (req, res) => {
_online: req.body.online ?? 0
});
addNewNode(newNode, (queryResults) => {
addNewNode(newNode, (newNodeObject) => {
// Send back a success if the user has been added and the ID for the client to keep track of
res.status(202).json({"nodeId": queryResults.insertId});
res.status(202).json({"nodeId": newNodeObject.id});
})
}
catch (err) {

View File

@@ -148,7 +148,7 @@ exports.addNewNode = async (nodeObject, callback) => {
// Call back the first (and theoretically only) row
// Specify 0 so downstream functions don't have to worry about it
return (callback) ? callback(returnNodeObjectFromRow(sqlResponse)) : returnNodeObjectFromRow(sqlResponse);
return (callback) ? callback(this.getNodeInfoFromId(sqlResponse.insertId)) : this.getNodeInfoFromId(sqlResponse.insertId);
}
/** Update the known info on a node