I am developing a reaction application, and I found a big problem, manipulating information from a priori rest.
I have a selection where the api by get method should bring me the client identifier, but I always get this error.
{error: "Client not found"} error: "Client not found"
Error image
I want to get an array with only the identifier of all clients to do this, I do this fetch function, but I don’t know what to add .then ((resposneValue) to get the correct. Map array, but then I get an error, so how the prototyping of the map is not interrupted.
here is my code:
getHistory() {
const {customer} = this.state
fetch(
DOMAIN+'/api/customers/'+customer._id, {
method: 'get',
dataType: 'json',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization':'Bearer '+this.props.token
}
})
.then((response) =>
{
return response.json();
})
.then((responseValue) => {
this.setState({customsId:responseValue});
console.log(responseValue);
})
}
Edit:
I have one more sample:
getCustomers(){
fetch(
DOMAIN+'/api/customers/shop/'+this.props.salon, {
method: 'get',
dataType: 'json',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization':'Bearer '+this.props.token
}
})
.then((response) =>
{
console.log(this.props.salon);
return response.json();
})
.then((responseData) => {
responseData.map(function (v) {
v.platform = v.app ? v.app.platform : null })
this.setState({customers:responseData});
})
.catch(function() {
console.log("error");
});
}
The .log console inside the then function will tell me this array:
(22) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0
:
{_id: "591d66f69ea5d935ed4b9ba9", shop: {…}, email:...

, , ?