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
31
32
33
// I was able to get this script to work from my browser console, but
// it's not working in ValTown or from Airtable's scripting environment.
// My best guess is that it has something to do with the headers not looking
// quite right to Substack when we hit their API.
const email = "hello.at.smallworld@gmail.com";
const body = {
additional_referring_pub_ids: "",
current_referrer: "",
current_url: "https://blog.edgeesmeralda.com/",
first_referrer: "",
first_url: "https://blog.edgeesmeralda.com/",
referral_code: "",
referring_pub_id: "",
source: "cover_page",
email,
};
const result = await fetch("https://blog.edgeesmeralda.com/api/v1/free", {
"headers": {
"content-type": "application/json",
"sec-ch-ua": "\"Not A(Brand\";v=\"99\", \"Google Chrome\";v=\"121\", \"Chromium\";v=\"121\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"Referer": "https://blog.edgeesmeralda.com/",
"Referrer-Policy": "strict-origin-when-cross-origin",
},
"body": JSON.stringify(body),
"method": "POST",
});
console.log(await result.json());
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.