Код: Выделить всё
const { data } = await axios.get(`/my/api/path/`, {
headers: {
Accept: 'application/json'
}
});
const axiosIntermediatePath = data.root.nested.path;
console.log('axiosIntermediatePath:', axiosIntermediatePath);
const fetchResponse = await fetch(`/my/api/path/`, {
headers: {
Accept: 'application/json'
}
});
const fetchData = await fetchResponse.json();
const fetchIntermediatePath = fetchData.root.nested.path
console.log('fetchIntermediatePath:', fetchIntermediatePath);
< /code>
axiosIntermediatePath:
{
...
"foo": {
"bar": "",
},
...
}
fetchIntermediatePath:
{
...
"foo": {
"bar": "myCorrectData",
},
...
}
< /code>
Even stranger, if I then immediately access the property, it
returns correctly:
console.log('axiosEditor:', axiosIntermediatePath.foo.bar);
console.log('fetchEditor:', fetchIntermediatePath.foo.bar);
< /code>
axiosEditor: myCorrectData
fetchEditor: myCorrectData
< /code>
I found this problem because I was using axiosПодробнее здесь: https://stackoverflow.com/questions/796 ... ted-object