S
S
Sergey Topolov2018-10-24 13:27:04
JavaScript
Sergey Topolov, 2018-10-24 13:27:04

How to write a proper Get request?

There is a shorter snag. I am making a parser. Everything seemed to be going ok. But the site of KopiKot does not lend itself. More precisely, I do not parse it myself. Opened a request to api in devtulls. The site itself on Angular is inconvenient. Here. In short - if you just drive in the url in the browser or in the postman - then everything is ok. and on NodeJS + Request-Promise (generally I think they are not the problem) - they don’t want to. I think some headers should be passed or library options. Do not hit hard, I did not finish my studies on the correct formulation of queries.
Test link - runkit

require("request/package.json");
var R = require("request-promise");

const xxx = async opt => await R({
    uri: 'https://api.kopikot.ru/campaigns?limit=10&offset=0&order=popularity',
    method: 'GET',
});
const yyy = await xxx();

console.log({yyy});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
qq1, 2018-10-24
@topus009

x-bonusway-localeHeading is neededru

require("request/package.json");
var R = require("request-promise");

const xxx = async opt => await R({
    uri: 'https://api.kopikot.ru/campaigns?limit=10&offset=0&order=popularity',
    method: 'GET',
    headers: {
        'x-bonusway-locale': 'ru'
    }
});
const yyy = await xxx();

console.log({yyy});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question