CW:产品类型所需的城市信息:: local_conditions'Here Map

问题描述 投票:0回答:1

我正在尝试获取有关天气的信息,但是当我对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'中我无法找到此错误的解决方案

node.js mongodb api express here-maps-rest
1个回答
0
投票

这应该是相当简单的,下面的代码对我有用:

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);
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.