Updated incoming_request_handlers.js to match database querying
This commit is contained in:
@@ -31,16 +31,19 @@ function handleIncoming(request, response, app, pool)
|
||||
else
|
||||
{
|
||||
// Send back the data in the right format
|
||||
let firstRow = rows[0];
|
||||
let converted = rows.map(row => {
|
||||
return {
|
||||
name: row.Name,
|
||||
description: row.Description,
|
||||
muscleGroup: row.MuscleGroup,
|
||||
imageUrl: row.ImageURL,
|
||||
videoUrl: row.VideoURL
|
||||
};
|
||||
});
|
||||
|
||||
response
|
||||
.status(200)
|
||||
.send(JSON.stringify({
|
||||
name: firstRow.Name,
|
||||
description: firstRow.Description,
|
||||
muscleGroup: firstRow.MuscleGroup,
|
||||
imageUrl: firstRow.ImageURL,
|
||||
videoUrl: firstRow.VideoURL
|
||||
}));
|
||||
.send(JSON.stringify(converted));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -64,5 +67,5 @@ function handleIncoming(request, response, app, pool)
|
||||
|
||||
// Export the function that registers the incoming request handlers
|
||||
module.exports = function(app, pool) {
|
||||
app.get('/', (req, res) => handleIncoming(req, res, app, pool));
|
||||
app.post('/', (req, res) => handleIncoming(req, res, app, pool));
|
||||
};
|
Reference in New Issue
Block a user