score:4
Accepted answer
i have already given answer:
let employee={
id:1,
name:'abc',
mobile:123456,
email:'abc@abc.com',
dept:'it',
role:'developer'
}
fetch('https://mywebsite.com/createnewemployee/', {
method: 'post',
headers: {
'accept': 'application/json',
'content-type': 'application/json',
},
body: json.stringify(employee)
})
.then(function(resp){
// your response
})
score:0
you can use axios library.
npm install axios --save
and then:
axios.post('/createnewemployee/', {
id:1,
name:'abc',
mobile:123456,
email:'abc@abc.com',
dept:'it',
role:'developer'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Source: stackoverflow.com
Related Query
- How to perfrom WEBAPI Post call from react Js?
- How to Render Data from a POST API call in React
- How to make a rest post call from ReactJS code?
- How do I call firebase functions from within a react component
- React Select - How to show / iterate through data from api call in option instead of hardcoding options?
- How to post data from react to express
- how and when to call a react component methods after state change from redux
- React - How do you call a function from inside another function
- How to call a component function on other component, but from the other component ? React
- react how to call state variable from another class?
- How to Call selector function from React Component?
- How to send url params from react to express api call
- How to send a fetch post request from react component to backend
- How to call multiple graphql mutation from a single react component?
- React js how to axios post from outside of component
- How to call parent function from child prop React 15.5.0
- How can I call a Parent function from a React functional component?
- How to call a function in react js from an external JS File
- React/ES6 -> How to call an React component class method from another component?
- How to call event from component after setting its state with React hooks?
- In React, how do I call a function in one component (which is being rendered with React Router) from another component?
- How to call dialog box from another file in React
- How to post a javascript array to MongoDB from react app?
- How to do Basic Authentication from React Axios GET call to a SpringBoot microservice
- How to send POST request from React front to PHP backend?
- how to call parent function controller from directive react component angularjs + reactjs?
- How do I post to facebook from my React app?
- How to call a function from a function both residing on a React Component
- How to set multiple states using one response from axios API call in React
- How to call child component's method from a parent component in React
More Query from same tag
- React.js - Having trouble creating a new invoice within my project
- "Flatten" Nested Object for Data Table
- Javascript: Unable to get Promises.all responses together
- Download modified excel file in react
- Divergent chart possible with Highcharts?
- How to determine deep in the React view hierarchy whether to use a Link or a callback?
- Protect routes react router dom 6
- CSP script-src strict-dynamic with hash is blocking host domain
- Chart refreshing twice
- Set attribute as variable in reactstrap
- Script is not executed in React JS
- Transform object array to new array structure
- Update without page refresh
- Error: useHref() may be used only in the context of a <Router> component. It works when I directly put the url as localhost:3000/experiences
- React: ReferenceError: regeneratorRuntime is not defined
- Unable to fetch list in react relay
- Can I transclude the children of the original element in ReactJS?
- how to add onClick function to array
- React Class passing stale props to Child stateless component
- JavaScript do expression: if statement without else
- How can I reapply style classes that get removed by ThemeProvider?
- How to get a prop value into a function from a Class in react?
- Video doesn't play on mobile - react application
- Creating a handler for fluent ui drop down, using a dynamic name for a React state
- React with firebase cloud firestore- presenting data from the database
- imperative logic on component that renders non-React components (mostly)
- Shouldn't useContext() only be used for low frequent updates? (mobx-react-lite)
- How to use the svg fill url in react
- How do I return values from a React component?
- How to delete an object from a list in React?