[FIX] REST for method calls not raising errors (#2408)
* [FIX] REST for Method calls not raising erorrs * Remove unnecessary lint disable
This commit is contained in:
parent
8841d17a44
commit
6555687891
|
@ -754,12 +754,17 @@ const RocketChat = {
|
|||
return this.methodCallWrapper('getUsersOfRoom', rid, allUsers, { skip, limit });
|
||||
},
|
||||
|
||||
async methodCallWrapper(method, ...params) {
|
||||
methodCallWrapper(method, ...params) {
|
||||
const { API_Use_REST_For_DDP_Calls } = reduxStore.getState().settings;
|
||||
if (API_Use_REST_For_DDP_Calls) {
|
||||
return new Promise(async(resolve, reject) => {
|
||||
const data = await this.post(`method.call/${ method }`, { message: JSON.stringify({ method, params }) });
|
||||
const { result } = JSON.parse(data.message);
|
||||
return result;
|
||||
const response = JSON.parse(data.message);
|
||||
if (response?.error) {
|
||||
return reject(response.error);
|
||||
}
|
||||
return resolve(response.result);
|
||||
});
|
||||
}
|
||||
return this.methodCall(method, ...params);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue