Manshul
Manshul
TTCTheo's Typesafe Cult
Created by Manshul on 11/21/2023 in #questions
Calling API based on the returned response
async function intervalCall() {
try {
const startResponse = await fetch(
"http://example/challenges?nickname=Bozo",
{ method: "POST" }
); //make the initial fetch call to start the challenge
const dataRes = await startResponse.json();
console.log(dataRes);

// {
// id: 'unique ID',
// actives_at: 1700570652300,
// called_at: 1700570651628,
// total_diff: 0
// }

let dataResId = dataRes.id;
let currentInterval = dataRes.total_diff;

if (currentInterval <= 500) {
const startResponsePut = await fetch(
"http://example/challenges?nickname=Bozo",
{ method: "PUT", headers: { "X-Challenge-Id": dataResId } }
); //make the PUT call with the challenge id untill the differrence is >500
const responsePutJson = await startResponsePut.json();
console.log(responsePutJson);
currentInterval += dataRes.total_diff;
} else {
console.log("Challenge interval exceeds 500");
}
} catch (error) {
console.log("Error", error);
}
}

// Call the function
intervalCall();
async function intervalCall() {
try {
const startResponse = await fetch(
"http://example/challenges?nickname=Bozo",
{ method: "POST" }
); //make the initial fetch call to start the challenge
const dataRes = await startResponse.json();
console.log(dataRes);

// {
// id: 'unique ID',
// actives_at: 1700570652300,
// called_at: 1700570651628,
// total_diff: 0
// }

let dataResId = dataRes.id;
let currentInterval = dataRes.total_diff;

if (currentInterval <= 500) {
const startResponsePut = await fetch(
"http://example/challenges?nickname=Bozo",
{ method: "PUT", headers: { "X-Challenge-Id": dataResId } }
); //make the PUT call with the challenge id untill the differrence is >500
const responsePutJson = await startResponsePut.json();
console.log(responsePutJson);
currentInterval += dataRes.total_diff;
} else {
console.log("Challenge interval exceeds 500");
}
} catch (error) {
console.log("Error", error);
}
}

// Call the function
intervalCall();
2 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
ok i will check it out thanks a lot!
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
damn looks like the things changed
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
getStaticProps/getStaticPaths <= this thing?
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
sorry im kinda nub and recently got back in prog
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
i though async was already doing the whole promise thing
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
add delay or something?
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
so like ... how do i fetch it?
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
damn... i didnt encounter this in the past so kinda confused
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
export async function getProjects() {
const res = await fetch(process.env.BASE_URL + "/api/projects");
if (!res.ok) {
throw new Error("failed");
}

return res.json();
}
export async function getProjects() {
const res = await fetch(process.env.BASE_URL + "/api/projects");
if (!res.ok) {
throw new Error("failed");
}

return res.json();
}
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
and also mentioned prisma client key and mongodb key
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
while fetching api and all
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
something like this for base url
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
since im deploying on vercel
36 replies
TTCTheo's Typesafe Cult
Created by Manshul on 9/29/2023 in #questions
vercel deployment failed
like instead of local host
36 replies