I fetch an API with the following code, which works like expected, but outputs the whole JSON object. How can I output only the value from answer/sichtbarkeitsindex/value
?
This is my code:
<code>function fetchApi() {
return fetch('https://api.sistrix.com/domain.sichtbarkeitsindex?api_key=myKey&format=json&domain=' + document.URL)
.then(response => {
if (!response.ok) {
return response.text().then(text => {throw new Error(text)});
}
return response.text();
})
}
return fetchApi()
.then(intent => seoSpider.data(intent))
.catch(error => seoSpider.error(error));
</code>
<code>function fetchApi() {
return fetch('https://api.sistrix.com/domain.sichtbarkeitsindex?api_key=myKey&format=json&domain=' + document.URL)
.then(response => {
if (!response.ok) {
return response.text().then(text => {throw new Error(text)});
}
return response.text();
})
}
return fetchApi()
.then(intent => seoSpider.data(intent))
.catch(error => seoSpider.error(error));
</code>
function fetchApi() {
return fetch('https://api.sistrix.com/domain.sichtbarkeitsindex?api_key=myKey&format=json&domain=' + document.URL)
.then(response => {
if (!response.ok) {
return response.text().then(text => {throw new Error(text)});
}
return response.text();
})
}
return fetchApi()
.then(intent => seoSpider.data(intent))
.catch(error => seoSpider.error(error));
And this is the whole response:
<code>[
{
"answer": [
{
"sichtbarkeitsindex": [
{
"date": "2024-04-22T00:00:00+02:00",
"domain": "example.com",
"value": 0.0142
}
]
}
],
"credits": [
{
"used": 1
}
],
"info": [
{
"country": "de",
"device": "mobile",
"domain": "example.com"
}
],
"method": [
[
"domain.sichtbarkeitsindex"
]
]
}
]
</code>
<code>[
{
"answer": [
{
"sichtbarkeitsindex": [
{
"date": "2024-04-22T00:00:00+02:00",
"domain": "example.com",
"value": 0.0142
}
]
}
],
"credits": [
{
"used": 1
}
],
"info": [
{
"country": "de",
"device": "mobile",
"domain": "example.com"
}
],
"method": [
[
"domain.sichtbarkeitsindex"
]
]
}
]
</code>
[
{
"answer": [
{
"sichtbarkeitsindex": [
{
"date": "2024-04-22T00:00:00+02:00",
"domain": "example.com",
"value": 0.0142
}
]
}
],
"credits": [
{
"used": 1
}
],
"info": [
{
"country": "de",
"device": "mobile",
"domain": "example.com"
}
],
"method": [
[
"domain.sichtbarkeitsindex"
]
]
}
]