장형준
장형준

Reputation: 31

Why is different pixabay api result between http request in browser and http request in nodejs?

js and request module and

I don`t know why different pixabay api result between http request in browser and http request in nodejs.

My code is:

var request = require('request');
var query = 'https://pixabay.com/api/?key='+config.pixabayKey+'&q=커피'+'&safesearch=true&lang=ko&page='+data.pixa_image_page+'&image_type='+data.pixa_image_type;
request(query, function(error, response, body){
    if(!error&&response.statusCode==200){
        var result =JSON.parse(body);
        console.log(body);
        socket.emit('pixa_image_result' , result);
    } else{
        socket.emit('pixa_image_result' , {result:false});
    }
});

and this result has only 2, but result in http same query request using web browser result is 500.

It is really same query. I don`t know why is different

Please help me.

Upvotes: 0

Views: 664

Answers (1)

Simon Steinberger
Simon Steinberger

Reputation: 6825

First off, the Pixabay API is limited to return up to 500 matches. The total number of available hits on the website is included only as a number in the API response.

In your case, make sure that the q param is properly URL encoded. The values of data.pixa_image_page and data.pixa_image_type in your request are unknown. If, for example, image_type is "vector", there will be fewer matches than for "photo".

Maybe that helps ...

Upvotes: 0

Related Questions