Have this code (ApiClient):
import axios from 'axios';
const BASE_URI = 'http://localhost:4433';
const client = axios.create({
baseURL: BASE_URI,
json: true
});
class APIClient {
constructor(accessToken) {
this.accessToken = accessToken;
}
removeUser(id){
return this.perform('delete', `/removeUser/${id}`);
}
checkStatus(uuid){
return this.perform('get', `/checkStatus?uuid=${uuid}`);
}
async perform (method, resource, data) {
return client({
method,
url: resource,
data,
headers: {
Authorization: `Bearer ${this.accessToken}`
}
}).then(resp => {
return resp.data ? resp.data : [];
})
}
}
export default APIClient;
In my component
removeUser = (id) => {
const uuid= this.apiClient.removeUser(id);
console.log(uuid);
this.setState({ uuid: uuid});
}
But somehow get a Promise Object with Pending
Prmomise { "pending" }
etc
New to ReactJS and JS world.
What is wrong here? Shouldn't uuid contain response from the DELETE endpoint request?