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:
@@ -38,9 +38,9 @@ exports.newNode = async (req, res) => {
|
|||||||
_online: req.body.online ?? 0
|
_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
|
// 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) {
|
catch (err) {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ exports.addNewNode = async (nodeObject, callback) => {
|
|||||||
|
|
||||||
// Call back the first (and theoretically only) row
|
// Call back the first (and theoretically only) row
|
||||||
// Specify 0 so downstream functions don't have to worry about it
|
// 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
|
/** Update the known info on a node
|
||||||
|
|||||||
Reference in New Issue
Block a user