mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
feat: send back missing parameters as array of missing properties, in API response
This commit is contained in:
@@ -441,7 +441,7 @@ helpers.formatApiResponse = async (statusCode, res, payload) => {
|
||||
const response = {};
|
||||
|
||||
// Update status code based on some common error codes
|
||||
switch (payload.message) {
|
||||
switch (message) {
|
||||
case '[[error:user-banned]]':
|
||||
Object.assign(response, await generateBannedResponse(res));
|
||||
// intentional fall through
|
||||
@@ -455,6 +455,11 @@ helpers.formatApiResponse = async (statusCode, res, payload) => {
|
||||
break;
|
||||
}
|
||||
|
||||
if (message.startsWith('[[error:required-parameters-missing, ')) {
|
||||
const params = message.slice('[[error:required-parameters-missing, '.length, -2).split(' ');
|
||||
Object.assign(response, { params });
|
||||
}
|
||||
|
||||
const returnPayload = await helpers.generateError(statusCode, message);
|
||||
returnPayload.response = response;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user