I'm using the here Traffic API, which should return something like this: {TIMESTAMP: "03/14/2021 19:40:57 GMT", VERSION: 5, TRAFFICITEMS: {…}}
It works most of the time, but every once in a while it returns this: {TIMESTAMP: "03/14/2021 19:40:57 GMT", VERSION: 5}
The second example would be if there were no traffic incidents, but further refreshes will return the first example. Nothing is changing in the code; I'm just refreshing the page. There are no errors regardless of the return; I just don't know why it's occasionally inaccurate
return fetch(`https://traffic.ls.hereapi.com/traffic/6.0/incidents.json?corridor=36.18377,-86.69355;36.08026,-86.92807;36.14638,-86.80963;36.18377,-86.69355%3B20&apiKey={API Key}`)
.then(res => {
if (res.ok) {
console.log("got a good response",res)
return res
} else {
console.log("you don't want that response")
}
})
.then(res => res.json())
.then(res => console.log("response",res))
The expected behavior is if there are no traffic incidents available, there is no trafficitems element in the response. What is the frequency of you refresh? Can you give exact timestamps when you are executing your requests reproducing your reported issue? There is a newer endpoint available: traffic.ls.hereapi.com/traffic/6.3/incidents.json