How to use the @aws-amplify/api.post 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 / Review / Review.tsx View on Github external
handleSubmit() {
		API.post("treehacks", '/review/rate', {
			body: {
				"application_id": this.state.application_data.user.id,
				...this.state.reviewFormData
			}
		}).then((data) => {
			if (data.results.status === "success") {
				this.nextApplication();
			}
		}).catch(err => {
			alert("Error, " + err);
			console.error(err);
		})
	}
}
github TreeHacks / root / src / Judge / Judge.tsx View on Github external
handleSubmit() {
		API.post("treehacks", '/judging/rate', {
			body: {
				"hack_id": this.state.hack_data._id,
				...this.state.reviewFormData
			}
		}).then((data) => {
			if (data.results.status === "success") {
				this.nextApplication();
			}
		}).catch(err => {
			alert("Error, " + err);
			console.error(err);
		})
	}
}
github TreeHacks / root / src / store / admin / actions.ts View on Github external
let csvData = null;
  const opts = { header: true, skipEmptyLines: true };
  if (status === STATUS.ADMITTED) {
    csvData = Papa.parse(headersAdmitted.join(",") + "\n" + ids, opts).data;
  }
  else {
    csvData = Papa.parse(headers.join(",") + "\n" + ids, opts).data;
  }
  for (let item of csvData) {
    if (item.__parsed_extra) {
      alert("Error: Too many fields are in a line. Please reformat the data.");
      return;
    }
  }
  dispatch(loadingStart());
  return API.post("treehacks", `/users_bulkchange`, {
    body: {
      ids: csvData,
      status: status
    }
  }).then(e => {
    dispatch(setBulkChangeIds(""));
    dispatch(setBulkChangeStatus(""));
    dispatch(loadingEnd());
  }).catch(e => {
    console.error(e);
    dispatch(loadingEnd());
    alert("Error performing bulk change: " + e);
  });
}
github TreeHacks / root / src / store / form / actions.ts View on Github external
export const declineAdmission = () => (dispatch, getState) => {
  const userId = (getState().auth as IAuthState).userId;
  dispatch(loadingStart());
  return API.post("treehacks", `/users/${userId}/status/decline`, {}).then(e => {
    dispatch(getUserProfile());
  }).catch(e => {
    console.error(e);
    dispatch(loadingEnd());
    alert("Error " + e);
  });
}
github TreeHacks / root / src / Judge / Judge.tsx View on Github external
skipHack() {
		if (!window.confirm(`Are you sure? This will mark table ${this.state.hack_data._id} as NOT HERE.`)) {
			return;
		}

		return API.post("treehacks", '/judging/rate', {
			body: {
				"hack_id": this.state.hack_data._id,
				"skip_hack": true
			}
		}).then((data) => {
			if (data.results.status === "success") {
				this.nextApplication();
			}
		}).catch(err => {
			alert("Error, " + err);
			console.error(err);
		})
	}
	nextApplication(id?: string) {
github awslabs / aws-full-stack-template / assets / src / modules / goal / AddEditGoal.tsx View on Github external
saveGoal = () => {
    const { goal } = this.state;
    return API.post("goals", "/goals", {
      body: {
        title: goal.title,
        content: goal.content
      }
    }).then((value: any) => {
      this.setState({
        isUpdating: false,
        redirect: '/'
      });
    });
  }
github TreeHacks / root / src / Rooms / Rooms.tsx View on Github external
onReserve(id, e) {
    e.preventDefault();
    API.post("treehacks", `/rooms`, { body: { room: id } })
      .then(this._updateFromApi)
      .catch(e => alert(`Couldn't reserve room: ${e.response.data.message}`));
  }