Reputation: 356
I have an express
POST router which sends data over to my other NodeJS script.
For example, I send over username, password
This is my script I want to send these parameters to
const options = {
cookiesPath: './cookies.json',
username: {I want to send username here},
password: {I want to send password here},
userslist: null,
dryrun: false,
}
This options
file is called again later in the code inside a different async
function by
const doWork = async (users = []) => {
usersToBeUsed = users;
const instauto = await Example(browser, options);
}
How can I catch these parameters in my const options
?
Upvotes: 0
Views: 814
Reputation: 1203
I suppose you're sending a form with two inputs named username and password and its values. Your route will look like this:
router.post("/my/path", controller.myFunction);
Then your function should look something like this:
exports.myFunction = (req, res) => {
console.log(req.body); //See how your data looks like
const options = {
cookiesPath: './cookies.json',
username: req.body.username,
password: req.body.password,
userslist: null,
dryrun: false,
};
//do something with the data and send the response, render, etc...
};
Upvotes: 1