Bing web search api key not working for some reason

痴心易碎 提交于 2019-12-24 18:33:21

问题


I am working on the Image Search Abstraction Layer FreeCodeCamp project and I got an API key for Bing Web Search API and I have installed node-bing-api npm module and added the key like this:

const Bing = require('node-bing-api')({accKey: "Key Here"});

and then I made a GET Request function to test if the API works or not, here is the function:

app.get('/search/imagesearch/:searchTerm:offset?', (req, res, next) => {
    var searchTerm = req.params.searchTerm;
    var offset = req.params.offset;
    // Search With API
    Bing.images(searchTerm, {
        count: 10,
        offset: offset
    }, (err, res, body) => {
        console.log(body);
    });
});

and it returns me this:

{ "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }

I have tried both of the API keys which it has given to me, I am still getting same error message, Can anyone suggest what can be the problem?

来源:https://stackoverflow.com/questions/47414372/bing-web-search-api-key-not-working-for-some-reason

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!