axios-mock-adapter
axios-mock-adapter copied to clipboard
Use Promise in mocked data
I made the mistake of doing this, and it cost me a bunch of time :
mockAxiosAdapter.onGet("/groups")
.replyOnce(200, Promise.resolve(groups));
Could it be possible to resolve Promises in the transformRequest(data)
function in handle_request.js
?
Thanks!
why you don't await the promises before and add to the mock just the returned data?
Please use the function based reply
or replyOnce
in that case.
.replyOnce(async function () {
return [200, await fetchGroups()]
});