Skip to content

Instantly share code, notes, and snippets.

@r1ckhenry
Created July 26, 2016 14:36
Show Gist options
  • Save r1ckhenry/516daafd61f479310022ef3fa1a7bf91 to your computer and use it in GitHub Desktop.
Save r1ckhenry/516daafd61f479310022ef3fa1a7bf91 to your computer and use it in GitHub Desktop.
Farm Manager

Farm Manager

  1. Add UPDATE action to server.js:
    • add route to handle update of existing document
  2. Add DELETE action to server.js
    • add route to handle deletion of existing document

Use Insomnia to test.

Extension ( not required ):

Add route to '/' in server.js and send back HTML form with JS script:

  • Create HTML form
  • onsubmit should send back AJAX Post request to update db
  • this code may help:
  var request = new XMLHttpRequest();
  request.open("POST", url);
  request.setRequestHeader("Content-Type", "application/json");
  request.onload = function(){
    if(request.status === 200){
    }
  }
  request.send(JSON.stringify( //**YOUR OBJECT HERE **//  ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment