Answer the question
In order to leave comments, you need to log in
How to generate a correct POST request in NodeJS to the VK server?
Good afternoon, please tell me how the post-request should look like to send a photo to the VK server or what mistakes were made in mine?
So I decided to do it, I used the axios package for nodejs and the answer came with an empty photo field
I can’t figure out what the problem is ...
Code for possible edits, those who want to answer:
const photo = new FormData();
//photo.append('photo', request('https://cdn.dribbble.com/users/1192832/screenshots/4721535/dribbble.png'));
photo.append('photo', fs.createReadStream('./1.png'),{name: 'photo', filename: '1.png', contentType: 'multipart/form-data'});
let axiosObj = {
method: 'post',
url: response_url,
photo: photo,
headers: photo.getHeaders()
}
axios({
method: axiosObj.method,
url: 'https://pu.vk.com/c856028/upload.php?act=do_add&mid=202775171&aid=-14&gid=129045983&hash=f3feb8fac0be43d9b2cbb5e1f73cddd1&rhash=6a15f35314df64a037812b0ea9df5143&swfupload=1&api=1&wallphoto=1',
photo: axiosObj.photo,
headers: axiosObj.headers
}).then(response =>{
console.log(response)
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question