Created
January 4, 2022 15:27
-
-
Save polluterofminds/7a12dfd0d593df25dbcb00055a28f00f to your computer and use it in GitHub Desktop.
Fetch Submarined CIDs and Generate Access Token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const findContent = await ky(`https://managed.mypinata.cloud/api/v1/content?cidContains=${cid}`, { | |
method: "GET", | |
headers: { | |
'x-api-key': API KEY | |
}, | |
}); | |
const results = await findContent.json(); | |
const item = results.items[0]; | |
const { id } = item; | |
const accessTokenParams = { | |
"timeoutSeconds": 30, | |
"contentIds": [id] | |
} | |
const accessToken = await ky(`https://managed.mypinata.cloud/api/v1/auth/content/jwt`, { | |
method: "POST", | |
headers: { | |
'x-api-key': API KEY | |
}, | |
body: accessTokenParams | |
}); | |
const tokenResult = await accessToken.json(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment