M
M
maistert2020-09-30 01:38:08
Node.js
maistert, 2020-09-30 01:38:08

How to send a GET request with form-data?

Hello dear forum users.
I use a third-party API, so I can't change anything on the "other side".
I need to send data of type form-data using the GET
o_O method

const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();
data.append('id', '0003175');

let config = {
  method: 'get',
  url: 'URL',
  headers: { 
    'Cookie': 'cabinet-web=cabinet-web-duo', 
    ...data.getHeaders()
  },
  data : data
};

axios(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

But when sending from the server, 400 comes and the catch is triggered.
Please let me know if anyone has experienced this.
Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question