Skip to content

Instantly share code, notes, and snippets.

@polluterofminds
Created January 4, 2022 15:27
Show Gist options
  • Save polluterofminds/7a12dfd0d593df25dbcb00055a28f00f to your computer and use it in GitHub Desktop.
Save polluterofminds/7a12dfd0d593df25dbcb00055a28f00f to your computer and use it in GitHub Desktop.
Fetch Submarined CIDs and Generate Access Token
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