I am looking to make a post request using axios with an object as the payload.
employee:{
name: 'test',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0d79687e794d6a606c6461236e6260">[email protected]</a>',
password: '123456',
role: {
created_at:"2018-08-03 07:34:30"
deleted_at:null
id:2
role_name:"employee"
updated_at:"2018-08-03 07:34:30"
}
},
This code snippet represents my post request:
axios.post('api/employees', vm.employee)
.then( response => {
alert("Employee Inserted");
vm.errors.clear();
vm.setFalse();
vm.fetchEmployees();
})
.catch( error => {
vm.errors.record(error.response.data);
});
My goal is to only pass in the 'role_name' attribute from the 'role' object along with 'name', 'email', and 'password' attributes in the post request. How can I achieve this?