CREATE_LINK: async()

in s12d/client/src/store/links.js [113:135]


    CREATE_LINK: async ({
      commit,
      dispatch,
      state
    }) => {
      if(reserveWords.includes(state.editLink.id.toLowerCase())){
        commit('FETCHING_ERROR', `"${state.editLink.id}" is a reserver word and cannot be used as a link.`);
      } else {
        commit('START_FETCHING');
        let response = await axios.post(`${apiUrl}/app/`, state.editLink, {
          headers: {
            Authorization: window.localStorage.getItem("cognitoIdentityToken"),
          },
        })
        if (response.data.error) {
          commit('FETCHING_ERROR', response.data.message);
          dispatch("SET_DETAILS", state.editLink.id)
        } else {
          commit('FETCHING_SUCCESS', {Items:[response.data]})
          router.push({name: 'dashboard'})
        }
      }
    },