Skip to content

Commit

Permalink
Merge pull request #9960 from marmelab/fix-ra-data-fakerest
Browse files Browse the repository at this point in the history
Fix logging of queries in ra-data-fakerest
  • Loading branch information
djhi authored Jun 26, 2024
2 parents ec450f7 + 3bf8f81 commit 3ad9ccd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/ra-data-fakerest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,27 @@ export default (data, loggingEnabled = false, delay?: number): DataProvider => {
* @param {Object} params The data request params, depending on the type
* @returns {Promise} The response
*/
const handle = (type, resource, params): Promise<any> => {
const handle = async (type, resource, params): Promise<any> => {
const collection = database.getCollection(resource);
if (!collection && type !== 'create') {
const error = new UndefinedResourceError(
`Undefined collection "${resource}"`
);
error.code = 1; // make that error detectable
return Promise.reject(error);
throw error;
}
let response;
try {
response = getResponse(type, resource, params);
response = await getResponse(type, resource, params);
} catch (error) {
console.error(error);
return Promise.reject(error);
throw error;
}
if (loggingEnabled) {
const { signal, ...paramsWithoutSignal } = params;
log(type, resource, paramsWithoutSignal, response);
}
return Promise.resolve(response);
return response;
};

return {
Expand Down

0 comments on commit 3ad9ccd

Please sign in to comment.