Slackbot
06/21/2023, 4:05 AMFabian Iwand
06/21/2023, 5:36 AMSam Mead
06/21/2023, 7:35 AMjson_df4 = fetch(`${finance_repo}df4.json`, {
headers: {
authorization: `token ${Secret("GITHUB_ACCESS_TOKEN")}`
}
}).then(res => res.json());
I have a feeling you can ditch await
, too. I think Observable does some auto-async stuff for you.Fabian Iwand
06/21/2023, 7:39 AM(await fetch(...)).json()
is equivalent to fetch(...).then(r => r.json())
.Sam Mead
06/21/2023, 7:46 AMawait
in that context (i.e. without declaring an async
function)? I was wondering if this might affect promise handlingFabian Iwand
06/21/2023, 7:54 AMSam Mead
06/21/2023, 7:56 AMS Lee
06/21/2023, 11:31 AMFabian Iwand
06/21/2023, 12:03 PMjson_df4
, or only for table_df4
?
2. If json_df4
is fine: Does its cell output show you an object with a content
property?
3. If yes, does the value of that property look like a base64 encode string?
4. If yes, what output do you get if you only call atob
on the value (without JSON.parse
?)S Lee
06/21/2023, 12:26 PMS Lee
06/21/2023, 12:29 PMFabian Iwand
06/21/2023, 12:30 PMS Lee
06/21/2023, 12:34 PMS Lee
06/21/2023, 12:41 PMFabian Iwand
06/21/2023, 12:42 PMS Lee
06/21/2023, 12:43 PMS Lee
06/21/2023, 12:45 PMS Lee
06/21/2023, 12:45 PMFabian Iwand
06/21/2023, 12:46 PMFabian Iwand
06/21/2023, 12:49 PMS Lee
06/21/2023, 12:50 PMS Lee
06/21/2023, 12:51 PM<https://github.com/nyc-tinker/finance/blob/master/df4.json>
Fabian Iwand
06/21/2023, 12:51 PMfetch(
"<https://api.github.com/repos/USER/REPO/contents/PATH/TO/FILE.json>",
{ headers: { Authorization: `Bearer ${Secret("MY_TOKEN")}` } }
)
.then(r => r.json())
.then(d => atob(d.content))
.then(d => JSON.parse(d))
Fabian Iwand
06/21/2023, 12:53 PMS Lee
06/21/2023, 12:59 PMFabian Iwand
06/21/2023, 1:02 PMAccept: application/vnd.github.raw
for files > 1MBFabian Iwand
06/21/2023, 1:03 PMS Lee
06/21/2023, 1:07 PMjson_df4 = (
await fetch(`${finance_repo}df4.json`, {
headers: {
authorization: `token ${Secret("GITHUB_ACCESS_TOKEN")}`,
accept: "application / vnd.github.v3.raw"
}
})
).json()
S Lee
06/21/2023, 1:08 PMS Lee
06/21/2023, 1:10 PM*/*
rather than applicationS Lee
06/21/2023, 1:11 PMFabian Iwand
06/21/2023, 1:14 PMS Lee
06/21/2023, 1:16 PMjson_df4 = (
await fetch(`${finance_repo}df4.json`, {
headers: {
authorization: `token ${Secret("GITHUB_ACCESS_TOKEN")}`,
accept: `application/vnd.github.v3.raw`
}
})
).json()
Fabian Iwand
06/21/2023, 1:18 PMS Lee
06/21/2023, 1:18 PMS Lee
06/21/2023, 1:18 PMS Lee
06/21/2023, 1:19 PMS Lee
06/21/2023, 1:20 PMFabian Iwand
06/21/2023, 1:20 PMaccept: "application/vnd.github.raw"
as header? (without the v3)?Fabian Iwand
06/21/2023, 1:21 PMS Lee
06/21/2023, 1:24 PMS Lee
06/21/2023, 1:24 PMFabian Iwand
06/21/2023, 1:26 PMFabian Iwand
06/21/2023, 1:27 PMS Lee
06/21/2023, 1:27 PMjson_df4 = Object {
name: "df.json"
path: "df.json"
sha: "70a9605c0f6a6d7335d7c737680ea4827140ca28"
size: 144997
url: "<https://api.github.com/repos/nyc-tinker/finance/contents/df.json?ref=master>"
html_url: "<https://github.com/nyc-tinker/finance/blob/master/df.json>"
git_url: "<https://api.github.com/repos/nyc-tinker/finance/git/blobs/70a9605c0f6a6d7335d7c737680ea4827140ca28>"
download_url: "<https://raw.githubusercontent.com/nyc-tinker/finan…aster/df.json?token=SDLKFJLK9283487979J>"
type: "file"
content: "W3siZGF0ZSI6ICIyMDIzLTA2LTE2IiwgInRpY2tlciI6ICJJTU…nRpY2tlciI6ICJJTkNZIiwgInByaWNlIjog\nNzMuMTR9XQ==\n"
encoding: "base64"
_links: Object {self: "<https://api.github.com/repos/nyc-tinker/finance/contents/df.json?ref=master>", git: "<https://api.github.com/repos/nyc-tinker/finance/git/blobs/70a9605c0f6a6d7335d7c737680ea4827140ca28>", html: "<https://github.com/nyc-tinker/finance/blob/master/df.json>"}
}
Fabian Iwand
06/21/2023, 1:28 PMheaders: { ... }
code 🙂S Lee
06/21/2023, 1:28 PMjson_df4 = (
await fetch(`${finance_repo}df.json`, {
headers: {
authorization: `token ${Secret("GITHUB_ACCESS_TOKEN")}`,
accept: `application/vnd.github.raw`
}
})
).json()
S Lee
06/21/2023, 1:29 PMFabian Iwand
06/21/2023, 1:30 PMapplication/vnd.github.raw+json
?S Lee
06/21/2023, 1:32 PMFabian Iwand
06/21/2023, 1:32 PMS Lee
06/21/2023, 1:33 PMS Lee
06/21/2023, 1:33 PMFabian Iwand
06/21/2023, 1:34 PMS Lee
06/21/2023, 1:34 PMS Lee
06/21/2023, 1:34 PMS Lee
06/21/2023, 1:34 PMFabian Iwand
06/21/2023, 1:36 PMS Lee
06/21/2023, 1:37 PMS Lee
06/21/2023, 1:38 PMS Lee
06/21/2023, 1:40 PMS Lee
06/21/2023, 1:43 PMS Lee
06/21/2023, 1:43 PMS Lee
06/21/2023, 1:44 PMS Lee
06/21/2023, 1:44 PMFabian Iwand
06/21/2023, 3:06 PMThat was a lot of brain damage for a client-side issueCall it "experience" 🙂