Refactor API response structure to use 'body' instead of 'data' for consistency across all endpoints. Update stub responses and documentation accordingly.
This commit is contained in:
@@ -11,14 +11,15 @@ const loadJSON = (filename) => {
|
||||
return JSON.parse(data);
|
||||
};
|
||||
|
||||
const respond = (res, data) => {
|
||||
res.json({ error: null, data });
|
||||
const respond = (res, body) => {
|
||||
res.json({ success: true, body });
|
||||
};
|
||||
|
||||
const respondError = (res, message, statusCode = 400) => {
|
||||
res.status(statusCode).json({
|
||||
error: { message },
|
||||
data: null
|
||||
success: false,
|
||||
body: null,
|
||||
error: { message }
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user