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);
  });

Related Query

More Query from same tag