This is now working locally
This commit is contained in:
parent
2182428e2c
commit
358ee3efae
2 changed files with 27 additions and 37 deletions
|
@ -52,7 +52,7 @@ if (document.getElementById("creditsAcquire")) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncWithApi(data) { // eslint-disable-line no-unused-vars
|
function syncWithApi(data) { // eslint-disable-line no-unused-vars
|
||||||
const address = data.address;
|
const address = data.address;
|
||||||
const code = data.code;
|
const code = data.code;
|
||||||
|
|
||||||
|
@ -60,37 +60,30 @@ async function syncWithApi(data) { // eslint-disable-line no-unused-vars
|
||||||
document.querySelector("developer-program").innerHTML =
|
document.querySelector("developer-program").innerHTML =
|
||||||
"<p><strong>There was an issue with accessing GitHub's API. Please try again later.</strong></p>";
|
"<p><strong>There was an issue with accessing GitHub's API. Please try again later.</strong></p>";
|
||||||
|
|
||||||
try {
|
fetch(`https://api.lbry.io/reward/new?github_token=${code}&reward_type=github_developer&wallet_address=${address}`)
|
||||||
// let result = await got(`https://${apiUrl}/reward/new?github_token=${code}&reward_type=github_developer&wallet_address=${data.address}`, { json: true });
|
.then(response => response.json())
|
||||||
|
.then(result => {
|
||||||
|
switch(true) {
|
||||||
|
case !result.success:
|
||||||
|
case result.error === "this reward is limited to 1 per person":
|
||||||
|
document.querySelector("developer-program").innerHTML =
|
||||||
|
"<p>You have already claimed this reward. This reward is limited to <strong>ONE</strong> per person. Your enthusiasm is appreciated.</p>";
|
||||||
|
break;
|
||||||
|
|
||||||
let result = await fetch(`https://api.lbry.io/reward/new?github_token=${code}&reward_type=github_developer&wallet_address=${address}`, {
|
case result.success:
|
||||||
headers: {
|
result = result.data;
|
||||||
"Content-Type": "application/json"
|
document.querySelector("developer-program").innerHTML =
|
||||||
},
|
`<p><strong>Success!</strong> Your wallet has been credited with ${result.reward_amount} LBC.</p><p>We have a great reference for the <a href="/api/sdk">LBRY SDK here</a> to help you get started.</p><p>You can see proof of this transaction on <a href="https://explorer.lbry.io/tx/${result.transaction_id}">our Blockain Explorer</a>.</p>`;
|
||||||
mode: "no-cors"
|
break;
|
||||||
}).then(response => {
|
|
||||||
console.log("————— response"); // eslint-disable-line no-console
|
|
||||||
console.log(response); // eslint-disable-line no-console
|
|
||||||
return response;
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("————— result"); // eslint-disable-line no-console
|
default:
|
||||||
console.log(result); // eslint-disable-line no-console
|
console.log(data); // eslint-disable-line no-console
|
||||||
// result = result.body.data;
|
break;
|
||||||
|
}
|
||||||
// document.querySelector("developer-program").innerHTML =
|
})
|
||||||
// `<p><strong>Success!</strong> Your wallet has been credited with ${result.reward_amount} LBC.</p><p>We have a great reference for the <a href="/api/sdk">LBRY SDK here</a> to help you get started.</p><p>You can see proof of this transaction on <a href="https://explorer.lbry.io/tx/${result.transaction_id}">our Blockain Explorer</a>.</p>`;
|
.catch(() => {
|
||||||
} catch(error) {
|
// Idk what the error would be (probably a 500) so let's just have this message
|
||||||
console.log(error); // eslint-disable-line no-console
|
|
||||||
|
|
||||||
if (!error.body) {
|
|
||||||
document.querySelector("developer-program").innerHTML =
|
document.querySelector("developer-program").innerHTML =
|
||||||
"<p><strong>LBRY API is down. Please try again later.</strong></p>";
|
"<p><strong>LBRY API is down. Please try again later.</strong></p>";
|
||||||
}
|
});
|
||||||
|
|
||||||
else {
|
|
||||||
document.querySelector("developer-program").innerHTML =
|
|
||||||
"<p>You have already claimed this reward. This reward is limited to <strong>ONE</strong> per person. Your enthusiasm is appreciated.</p>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,11 @@ import fetchMetadata from "@helper/fetch-metadata";
|
||||||
import { generateGitHubFeed } from "@helper/github";
|
import { generateGitHubFeed } from "@helper/github";
|
||||||
import messageSlack from "@helper/slack";
|
import messageSlack from "@helper/slack";
|
||||||
|
|
||||||
// let apiUrl = process.env.REWARD_URL;
|
const githubAppId = process.env.GITHUB_APP_ID;
|
||||||
// let apiUrl = process.env.REWARD_URL_TEST;
|
const githubAppSecret = process.env.GITHUB_APP_SECRET;
|
||||||
|
|
||||||
// let githubAppId = process.env.GITHUB_APP_ID;
|
// const githubAppId = process.env.GITHUB_APP_ID_TEST;
|
||||||
// let githubAppSecret = process.env.GITHUB_APP_SECRET;
|
// const githubAppSecret = process.env.GITHUB_APP_SECRET_TEST;
|
||||||
|
|
||||||
let githubAppId = process.env.GITHUB_APP_ID_TEST;
|
|
||||||
let githubAppSecret = process.env.GITHUB_APP_SECRET_TEST;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue