CW: информация о городе, необходимая для типа продукта :: local_conditions 'Here Map - PullRequest
0 голосов
/ 13 марта 2019

Я пытаюсь получить информацию о погоде, но когда я делаю простой пост-запрос к API, получаю этот результат

`https://weather.api.here.com/weather/1.0/report.json?app_id=${appId}&app_code=${appCode}&product=observation&name=${city}`
{ Type: 'Invalid Request',
[0]   Message:
[0]    [ 'CW: City Information Required for product type::local_conditions' ] }

в документации 'https://developer.here.com' Я не могу найти решениеза эту ошибку

1 Ответ

0 голосов
/ 13 марта 2019

Это должно быть довольно просто, код ниже работает для меня:

const request = require('request');

const options = {
    method: 'GET',
    url: 'https://weather.api.here.com/weather/1.0/report.json',
    qs: {
        app_id: appId, // Put your APP_ID here
        app_code: appCode, // Put your APP_CODE here
        product: 'observation',
        name: 'Berlin' // Put whichever location here
    }
}

request(options, (error, response, body) => {
    if (error) {
        console.error("An error has occurred: ", error);
    } else {
        console.log("Response body: ", body);
    }
});
...