Logout
Logged in users can logout using the API described below. The logout operation requires two properties: one marked as user id identity and the second is token.
Method : POST
URL : /api/logout
Body : JSON
{
"user_id": 2,
"token": "mdLDoIfP7zznp4cqQJ0ZHm-B1QxYA1y43DDqn2uYPmk"
}
Request :
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"user_id": 2,
"token": "mdLDoIfP7zznp4cqQJ0ZHm-B1QxYA1y43DDqn2uYPmk"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("/api/logout", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Response : 200 - OK
{
"message": "Success delete session"
}
Response :
{
"error_code": "422",
"message": "Unprocessable Content",
"error": "User id required",
"error": "Token required"
}