So I am trying to do something like this first:
From
//// test.js
const data1 = require(“./search-recent.json”);
const theData1 = data1.data[1].id;app.post(“/tweets”, function (req, res) {
res.json({ body: theData1 });});
Then in the very same page…
app.get(“/tweets”, async function (req, res) {
try {
const message = req.body;
const tweets = await client.tweets.createTweet({
text: message,
});
res.send(tweets);
} catch (error) {
console.log(“tweets error”, error);
}
});
And I get:
error: {
errors: [ [Object] ],
Worth to say I am working with EJS and the page /tweets is actually under views/tweets.ejs
How can I pass the variable of theData1 and catch it at the app.get section?