How to use the @aws-amplify/api.patch function in @aws-amplify/api

To help you get started, we’ve selected a few @aws-amplify/api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TreeHacks / root / src / store / admin / actions.ts View on Github external
export const editRow = (endpoint, rowId, data) => (dispatch, getState) => {
  dispatch(loadingStart());
  return API.patch("treehacks", `/${endpoint}/${rowId}`, {
    body: data
  }).then(e => {
    const adminState = (getState().admin as IAdminState);
    const applicationList = adminState.applicationList;
    let application = find(applicationList, { "_id": rowId });
    for (let key in data) {
      set(application, key, data[key]);
    }
    dispatch(setApplicationList(applicationList, adminState.pages)); // So that the table refreshes
    dispatch(loadingEnd());
  }).catch(e => {
    console.error(e);
    dispatch(loadingEnd());
    alert("Error performing edit row " + e);
  });
}