LoginSignup
0
0

More than 5 years have passed since last update.

Redux-Offline > POSTでデータ送信方法

Posted at

Make your offline-first React app with Redux-Offline - David Tran

Redux Offline – 构建离线优先的Web和React Native Apps - JavaScript开发 - 评论 | CTOLib码库

以下を参考にした

My code:

dispatch({
      ...executingDispatch,
      meta: {
        offline: {
          effect: {
            url: GRAPHQL_URL,
            method: TYPE_POST,
            body: JSON.stringify(query),
            headers: buildHeaders(token)
          },
          commit: { type: WARDROBE_ITEMS_SUCCESS, value: { params } },
          rollback: dispatchErrorAlertObject()
        }
      }
    });
export const postQRCodeData = jsonBody => ({
  type: types.POST_QRDATA_TYPE,
  payload: { jsonBody },
  meta: {
    offline: {
      // the network action to execute:
      effect: { url: urlList.urlQRSave, method: 'POST', body: JSON.stringify(jsonBody)  },
      // action to dispatch when effect succeeds:
      commit: { type: types.RECEIVE_QRDATA_RESULT_TYPE, meta: { jsonBody } },
      // action to dispatch if network action fails permanently:
      rollback: { type: types.RECEIVE_ERROR_QRDATA_RESULT_TYPE, meta: { jsonBody } }
    }
  }
});

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0