Answers for "slack file upload axios"

0

slack file upload axios

const fs = require("fs"); 
const axios = require("axios");
const FormData = require("form-data");


const form = new FormData();

form.append("token", 'token here');
form.append("channels", channelId);
form.append("file", fs.createReadStream(__dirname + "/aapl.png"), 'file name');

try {
  const res = await axios.post("https://slack.com/api/files.upload", form, {
    headers: form.getHeaders(),
  });
} catch (err) {
  throw new Error(err);
}
Posted by: Guest on March-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language