Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

axios post request

import axios from "axios";
/// POST REQUEST
addCity(data)
  .then((res) => {
      console.log(res);
      alert("success");
	});

export function addCity(data = {}) {
  // console.log(data);
  // {name: "mysore", population: 11111, country: "India"}
  return axios.post("URL", {
    name: data.name,
    population: data.population,
    country: data.country
  });
}
Source by masteringjs.io #
 
PREVIOUS NEXT
Tagged: #axios #post #request
ADD COMMENT
Topic
Name
8+8 =