Bing web search api key not working for some reaso

2019-08-27 03:34发布

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?

0条回答
登录 后发表回答