-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen.mjs
More file actions
29 lines (21 loc) · 695 Bytes
/
Copy pathopen.mjs
File metadata and controls
29 lines (21 loc) · 695 Bytes
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
import alfy from "alfy";
import fs from "fs/promises";
import path from "path";
import axios from "axios";
import { fileURLToPath } from "url";
import open from "open";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const query = alfy.input;
const token = alfy.config.get("token");
// get email html content
const { data } = await axios.get(`https://api.mail.tm/messages/${query}`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
// write html content to file
const html = data.html[0];
await fs.writeFile(path.join(__dirname, "email.html"), html, "utf8");
// email.html file path
const filePath = path.join(__dirname, "email.html");
await open(filePath);