1

I'm creating an application that outputs employee data based on user search, I want to upload this to my slackbot and I'm trying to use files.upload. I'm a beginner in node so I don't know how to convert my output to a file so I can upload it to Slack.

1 Answer 1

1

It is so simple. Let's see an example. Lets you get data from a database

const fs = require('fs');
let directory = '/temp/data';
let dbdata= 'Hello' // this data you got from database

fs.writeFile(directory, dbdata, function(err) {
if(err) {
    return console.log(err);
}
console.log("File has been saved");
}); 

// if you want synchronous then you can use this
fs.writeFileSync(directory, dbdata);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.