如何使用node.js向图像服务器发出发布请求

时间:2020-08-30 03:12:12

标签: node.js

我正在尝试将图像上传到图像服务器,代码没有问题,但是由于某种原因,图像服务器仅返回错误。有人知道代码是否有任何问题?

const axios = require("axios");
const fs = require("fs")

fs.readFile('image.png', (err, data) => {
  if (err) throw err;
  console.log(data);
    axios.post('https://img.ays.best/upload.php', {
  image: data,
  password: `i put my real password here`
}).then((response) => {
  console.log(response.data);
}, (error) => {
  console.log(error);
});
});

0 个答案:

没有答案