Almost a year ago, I wrote Redux and Forms and APIs, Oh My!. It introduced an adapter to make Redux form and redux-api-middleware work together, but only worked with Redux form 4.x and 5.x. Since then, Redux form 6.x has come out, and it requires a small update.

Redux Form 6 was a big change, but fortunately only requires a small change the adapter function:

Redux Form 6 formApiAdapter
export function formApiAdapter(dispatch, actionCreator) {
return (...args) =>
new Promise((resolve, reject) => {
dispatch(actionCreator(...args)).then(response => {
if (response.error) {
reject(new SubmissionError(formatErrors(response)))
} else {
resolve(response)
}
})
})
}
function formatErrors(response) {
// ...translate your API's error response into a redux-form-compatible error object
}

The only difference from the original is on line 6: We have to wrap the result of formatErrors in a new SubmissionError(...).