I have button on click it make request access to api For the first time it succeeds but second time it fails The parameter PromiseStatus in first time pending, and in second time this parameter worth resolved.
This code in my service:
function commandEndInstallation() {
const requestOptions = {
method: 'POST',
headers:{ 'Content-Type': 'application/json' }
};
return fetch(`${config.apiUrl}/Commands/PostCommandEndInstallation`, requestOptions).then(handleResponse);}
function handleResponse(response) {
return response.text().then(text => {
const data = text && JSON.parse(text);
if (!response.ok) {
if (response.status === 401) {
location.reload(true);
}
const error = (data && data.Message) || response.statusText;
return Promise.reject(error);
}
return data;
});}