Skip to content

BREAKING API: return payload.response/error and payload.request

Compare
Choose a tag to compare
@FredericHeem FredericHeem released this 28 Jul 20:26
· 64 commits to master since this release

This is, unfortunately, a breaking API change. The ok and error action now provide an object containing the response/error and request which is the array of the input parameters

BEFORE:

let reducer = createReducer({
    [login.request]: (state, payload) => ({
        ...state,
        request: payload,
        loading: true,
        error: null
    }),
    [login.ok]: (state, payload) => ({
        ...state,
        loading: false,
        data: payload // Change to payload.response
    }),
    [login.error]: (state, payload) => ({
        ...state,
        loading: false,
        error: payload // Change to payload.error
    }),
}, defaultsState);

NOW:

let reducer = createReducer({
    [login.request]: (state, payload) => ({
        ...state,
        request: payload,
        loading: true,
        error: null
    }),
    [login.ok]: (state, payload) => ({
        ...state,
        loading: false,
        data: payload.response // payload.request is now available
    }),
    [login.error]: (state, payload) => ({
        ...state,
        loading: false,
        error: payload.error // payload.request is now available
    }),
}, defaultsState);

See https://github.com/FredericHeem/starhackit/pull/127/files for the changes of the Starhackit project.