How to use the aws-amplify.API.post function in aws-amplify

To help you get started, we’ve selected a few aws-amplify 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 aws-samples / connected-drink-dispenser-workshop / dispenser_app / src / views / Home.vue View on Github external
async created() {
    if (this.$store.getters.isAuth == true) {
      // If created with valid authentication, read in user assets,
      // read initial dispenser status then sub to MQTT topics
      let response;
      let authInfo;
      let mqttResponse;
      authInfo = await Auth.currentUserInfo();
      response = await API.post("CDD_API", "/getResources", {
        body: { cognitoIdentityId: authInfo.id }
      });
      console.log("resources response is ", response)
      // Get resources needed to complete setup
      await this.$store.dispatch("setAssets", response);
      // Read dispenser shadow and credit status, and set
      response = await API.get("CDD_API", "/status");
      this.$store.dispatch("setStatus", response);
      this.sub1
        .subscribe([
          "".concat("events/", this.$store.getters.dispenserId),
          "".concat("$aws/things/", this.$store.getters.dispenserId, "/shadow/update/accepted")
        ])
        .subscribe({
          next: async () => {
            // Use the event to trigger a getResources call
github mbudm / fotopia-serverless / test / remote / api.js View on Github external
export const post = (hostname, route, params) => API.post(endpointName, route, params);
export const get = (hostname, route) => API.get(endpointName, route);
github forgepwa / the_forge / yolo / public / my-project / src / Home.jsx View on Github external
initRestaurant = async () => {

        API.post('ReactSample','/items/init')
            .then(data => {
                alert('Successfully inserted restaurants');
                this.setState({
                    data: data,
                    loading: false
                });
            })
            .catch (err => console.log(err))
    }
github forgepwa / the_forge / yolo / public / my-project / src / API / Menu.jsx View on Github external
orderItem = async (restaurantId,itemId) => {
        let requestParams = {
            headers: {'content-type': 'application/json'},
            body : {
                'restaurant_id': restaurantId,
                'menu_items': [{
                    'id':itemId,
                    'quantity': 1
                }]
            }
        }
        
        API.post('ReactSample','/items/orders', requestParams)
            .then(data => {
                sessionStorage.setItem('latestOrder', data.id);
                console.log(data);
                alert('Ordered successfully');
            })
            .catch (err => console.log(err))
    }
github AnomalyInnovations / serverless-stack-demo-client / src / containers / Settings.js View on Github external
function billUser(details) {
    return API.post("notes", "/billing", {
      body: details
    });
  }
github fourTheorem / slic-starter / frontend / src / actions / checklists.js View on Github external
return function(dispatch) {
    dispatch({ type: CREATE_LIST_REQUEST })
    AmplifyApi.post('checklist-api', '', {
      body: {
        name,
        description
      }
    })
      .then(result => {
        dispatch({ type: CREATE_LIST_SUCCESS, payload: result })
      })
      .catch(err => {
        dispatch({ type: CREATE_LIST_FAILURE, error: translateError(err) })
      })
  }
}
github aws-samples / aws-mobile-react-native-starter / client / src / Screens / AddPet.js View on Github external
async apiSavePet(pet) {
    return await API.post('Pets', '/items/pets', { body: pet });
  }