You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to use that method to serialize incoming failed responses, but the responses might come in as a ResponseError - where getting the response body is an asynchronous operation.
In the meantime, I can continue using a try/catch in the payload creator. Alternatively, I could maybe be able to get around this by returning a SerializedError, then mutating it on Promise.then, but I'm really not sure if the latter is something I should consider.
changed the title [-]Can serializeError in AsyncThunkOptions be updated to be async (for async calls like Response.text() that might be helpful)?[/-][+]Can serializeError in AsyncThunkOptions be updated to be async (could be helpful for async calls like Response.text())?[/+]on Aug 7, 2023
Possibly. Right now the call to serializeError() happens inside of the rejected() action prepare callback, which has to be sync. We could move that out to do the serialization call in the body of the thunk and make it async. But, this is low priority for us atm. If anyone wants to file a PR we can look at it.
Can serializeError in AsyncThunkOptions be updated to be async (could be helpful for async calls like Response.text())? · Issue #3645 · reduxjs/redux-toolkit
Activity
[-]Can serializeError in AsyncThunkOptions be updated to be async (for async calls like Response.text() that might be helpful)?[/-][+]Can serializeError in AsyncThunkOptions be updated to be async (could be helpful for async calls like Response.text())?[/+]markerikson commentedon Aug 16, 2023
Possibly. Right now the call to
serializeError()
happens inside of therejected()
action prepare callback, which has to be sync. We could move that out to do the serialization call in the body of the thunk and make it async. But, this is low priority for us atm. If anyone wants to file a PR we can look at it.