Answer the question
In order to leave comments, you need to log in
How to execute http delete in angularjs?
Hello. I can't figure out how to execute a delete type request in angularjs. The server has a rest api, it waits for two input parameters. I do it like this:
$http.delete('http://api/v1/contacts/index/', {params: {id_user: $localStorage.userAuthData.id_user, id_contact: id_contact}})
.success(function(data)
{
}
});
function index_delete()
{
$id_user = $this->delete("id_user");
$id_contact = $this->delete("id_contact");
if (!empty($id_user) && !empty($id_contact))
{
if ($id_user == $this->data_token->id_user)
{
$data_contacts = array(
'id_user' => $id_user,
'id_contact' => $id_contact
);
if ($this->contacts_model->delete_contact($data_contacts))
{
$data_response = array(
'status' => 'success',
'response' => $data_contacts
);
$this->response($data_response, 200);
}
else
{
$data_response = array(
'status' => 'failed',
'response' => 'Error delete contact.'
);
$this->response($data_response, 500);
}
}
else
{
$data_response = array(
'status' => 'failed',
'response' => 'User with the token does not exist.'
);
$this->response($data_response, 404);
}
}
else
{
$data_response = array(
'status' => 'failed',
'response' => 'Data were not obtained or is not valid.'
);
$this->response($data_response, 500);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question