POST request


#1

I want to send data to backend using POST request. I am using axios for this purpose. Could anyone help me more in knowing about how to send the data to backend using post request ( DATA should be sent as key value pair).

I am also enclosing the code for reference


  onNewRequest(searchTerm) {
         axios.post('https://app.alumna10.hasura-app.io/backend',searchTerm)
              .then(response => {
                  console.log(response)
                  alert(response);
      });
}

The above is the code, the data is in “searchTerm” at present. “searchTerm” is a variable.

Please do help me in this .


#2

adding error checking is always a good idea:

searchTerm = {test: "hello world"}

axios.post('https://app.alumna10.hasura-app.io/backend',searchTerm)
  .then(response => {
    console.log(response)
    alert(response);
  })
  .catch(error => {
    console.log(error);
  });

what is search term? Can we make a request to replicate the problem? What response are you getting and so on? What is used on the back-end?