G
G
GreatX2019-08-14 06:18:07
Node.js
GreatX, 2019-08-14 06:18:07

It's not clear how to pass the API key, axios library?

The data is the same, but in the case of axios it returns the wrong key. Why is that? help me please

axios({
        method: 'post',
        url: URL + 'get_products',
        data: {
            secret:  secret 
        }
    })
    .then(data=>console.log(data))
    .catch(err=>console.log(err))

HttpRequest.post(URL + 'get_products', { form: { secret: secret } }, function (err, res, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        else {
            let data = JSON.parse(body);
            console.log('======================================\n', data.name[0]);
        }
    })

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly B, 2019-08-14
@vitaliy_balahnin

Maybe Trouble in the headers?
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },

A
Andrey Suha, 2019-08-14
@andreysuha

Axios
key: secret
HttpRequest
secret: secret
You name the parameter differently

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question