So I have an Azure Function that calls Microsoft Maps API and it works (sometimes). However at times it throws this error during the request. Please advise.
My Code:
const options =
{
host: 'atlas.microsoft.com', //added this later
headers: { 'x-ms-client-id': client_id }
}
//url to get lat/long
let url = 'https://atlas.microsoft.com/search/fuzzy/json?api-version=1.0&subscription-key=' + subscription_key + '&query=' + address + ' USA'
//make req
let res = await axios.get(url, options)
Response/Error:
{
"error": {
"message": "connect ETIMEDOUT XX.XXX.XX.XX:XXX",
"name": "Error",
"stack": "Error: connect ETIMEDOUT XX.XXX.XX.XX:XXX\n at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)",
"config": {
"url": "https://atlas.microsoft.com/search/fuzzy/json?api-version=1.0&subscription-key=myKey&query=myQuery",
"method": "get",
"headers": {
"Accept": "application/json, text/plain, */*",
"x-ms-client-id": myClientID,
"User-Agent": "axios/0.19.2"
},
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"host": "atlas.microsoft.com"
},
"code": "ETIMEDOUT"
}
}