#zeke_error

1 messages ¡ Page 1 of 1 (latest)

hollow spireBOT
frozen lintelBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

hollow spireBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1261439703735996448

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

dark jay
#

import { stripe } from "@/lib/stripe";

export default async function handler(
req: { method: string; body: { account: any }; headers: { origin: any } },
res: {
json: (arg0: { url: any }) => void;
status: (arg0: number) => void;
send: (arg0: { error: any }) => void;
}
) {
if (req.method === "POST") {
try {
const { account } = req.body;

  const accountLink = await stripe.accountLinks.create({
    account: account,
    refresh_url: `${req.headers.origin}/refresh/${account}`,
    return_url: `${req.headers.origin}/return/${account}`,
    type: "account_onboarding",
  });

  res.json({
    url: accountLink.url,
  });
} catch (error) {
  console.error(
    "An error occurred when calling the Stripe API to create an account link:",
    error
  );
  res.status(500);
  //@ts-expect-error
  res.send({ error: error.message });
}

}
}

#

Hi two-shoes happy Friday!

wraith moth
#

What's the actual error message you're getting?

dark jay
#

its not exactly an error its a network status of an Endpoint

#

if you would like a ss I can provide

#

Im going to go work on more stuff for my business just @ me and Ill hear the jingle!

wraith moth
#

I don't know if we can really help much with that. If you don't have any browser console errors, network errors, or anything tangible to point to, we're kind of flying blind. It also sounds like this might not even be on the Stripe side of things, so we might not even be good folks to ask to begin with.

dark jay
#

Ok I was just wondering because it was from your docs!

#

do you think it is a front end or backend error?

#

if you had to guess

wraith moth
#

Error Message
account_link status (pending) type fetch
What console does this error show up in?

dark jay
#

my console

#

crome*

wraith moth
#

Where does that other network request go? Click on it

dark jay
#

The account one?

wraith moth
#

I just need to see the headers for the pending network request

dark jay
#

there are no response headers

wraith moth
#

Okay, yeah. So the fetch() is waiting for the back-end to send something back.

I notice that you're not sending back an HTTP 200 anywhere in your back-end code, so that's probably what's going wrong

dark jay
#

which would be this code right here:

import { stripe } from "@/lib/stripe";

export default async function handler(
req: { method: string; body: { account: any }; headers: { origin: any } },
res: {
json: (arg0: { url: any }) => void;
status: (arg0: number) => void;
send: (arg0: { error: any }) => void;
}
) {
if (req.method === "POST") {
try {
const { account } = req.body;
console.log("Received account ID:", account); // Logging the received account ID

  const accountLink = await stripe.accountLinks.create({
    account: account,
    refresh_url: `${req.headers.origin}/refresh/${account}`,
    return_url: `${req.headers.origin}/return/${account}`,
    type: "account_onboarding",
  });

  console.log("Account link created:", accountLink); // Logging the created account link

  res.json({
    url: accountLink.url,
  });
} catch (error) {
  console.error(
    "An error occurred when calling the Stripe API to create an account link:",
    error
  );
  res.status(500);
  //@ts-expect-error
  res.send({ error: error.message });
}

}
}

wraith moth
#

Yup

dark jay
#

ok so I just need to send a HTTP 200 in this code

wraith moth
#

Yup, you can just put res.send(); in your if statement such that it fires when no error is present

dark jay
#

ok let me try that ill be right back

wraith moth
#

We close at 3:30, so let me know if anything happens before then and I'll try to answer your questions before I go

dark jay
#

Hmm its still pending

#

import { stripe } from "@/lib/stripe";

export default async function handler(
req: { method: string; body: { account: any }; headers: { origin: any } },
res: {
json: (arg0: { url: any }) => void;
status: (arg0: number) => void;
send: (arg0?: { error?: any }) => void;
}
) {
if (req.method === "POST") {
try {
const { account } = req.body;
console.log("Received account ID:", account); // Logging the received account ID

  const accountLink = await stripe.accountLinks.create({
    account: account,
    refresh_url: `${req.headers.origin}/refresh/${account}`,
    return_url: `${req.headers.origin}/return/${account}`,
    type: "account_onboarding",
  });

  console.log("Account link created:", accountLink); // Logging the created account link

  res.json({
    url: accountLink.url,
  });

  // Send response indicating success
  res.send();
} catch (error) {
  console.error(
    "An error occurred when calling the Stripe API to create an account link:",
    error
  );
  res.status(500);
  //@ts-expect-error
  res.send({ error: error.message });
}

}
}

#

did I do that correctly?

wraith moth
#

Try replacing this:
`res.json({
url: accountLink.url,
});

  // Send response indicating success
  res.send();`

With this:
res.send({ url: accountLink.url });

dark jay
#

Ok ill go qucik!

wraith moth
#

Sorry for the edits. It was a copy/paste from my own code that I sent at first

dark jay
#

I get this error Object literal may only specify known properties, and 'url' does not exist in type '{ error?: any; }'.ts(2353)
(property) url: any

#

its fine Ill figure it out I know you have to leave!!!!

#

I dont want you to work overtime!!

#

Have a good weekend!

#

will i still be able to see this thread?

wraith moth
#

I think that's just a Typescript compiler error. Unfortunately I gotta go, but hopefully you're able to Google that and figure out how to fix it.

If worst comes to worst, just use a Typescript ignore on that line with @ts-ignore

wraith moth
#

Have a good weekend!

dark jay
#

ok Sweet!!!