public/src/js/feed.js
// helper function to send data directly to the server
helper function to send data directly to the server
helper function to send data directly to the server
function sendData() {
  const id = new Date().toISOString()
  const postData = new FormData();
  postData.append('id', id);
  postData.append('title', titleInput.value);
  postData.append('location', locationInput.value);
  postData.append('rawLocationLat', fetchedLocation.lat);
  postData.append('rawLocationLng', fetchedLocation.lng);
  postData.append('file', picture, `${id}.png`);
  fetch('https://us-central1-pwa-facer.cloudfunctions.net/storePostData', {
    method: 'POST',
    body: postData,
  })
    .then((res) => {
      const snackbarContainer = document.querySelector('#confirmation-toast');
      const data = { message: '☁ Upload complete!' };
      snackbarContainer.MaterialSnackbar.showSnackbar(data);
      console.log('Sent data', res);
      updateUI();
    });
}
function sendData ( ) { const id = new Date ( ) . toISOString ( ) const postData = new FormData ( ) ; postData . append ( 'id' , id ) ; postData . append ( 'title' , titleInput . value ) ; postData . append ( 'location' , locationInput . value ) ; postData . append ( 'rawLocationLat' , fetchedLocation . lat ) ; postData . append ( 'rawLocationLng' , fetchedLocation . lng ) ; postData . append ( 'file' , picture , ` ${ id } ` ) ; fetch ( 'https://us-central1-pwa-facer.cloudfunctions.net/storePostData' , { method : 'POST' , body : postData , } ) . then ( ( res ) => { const snackbarContainer = document . querySelector ( '#confirmation-toast' ) ; const data = { message : '☁ Upload complete!' } snackbarContainer . MaterialSnackbar . showSnackbar ( data ) ; console . log ( 'Sent data' , res ) ; updateUI ( ) ; } ) ; }
helper function to send data directly to the server
helper function to send data directly to the server