-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (25 loc) · 837 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import fetch from "node-fetch";
import Twit from "twit";
import { config } from "dotenv";
config();
const twitterClient = new Twit({
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token: process.env.TWITTER_ACCESS_TOKEN,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
});
const sendAphorism = async () => {
try {
const response = await fetch("https://partitasmusic.com/api/aphorism");
const aphorism = await response.text();
const aphorismWithQuotes = `"${aphorism}"`;
console.log(aphorismWithQuotes);
// Twitter
await twitterClient.post("statuses/update", {
status: aphorismWithQuotes,
});
} catch (error) {
console.error("Error fetching or sending aphorism", error);
}
};
export default sendAphorism;