[Deno] Invalid JSON received from the Stripe API
See original GitHub issueDescribe the bug
stripe.accounts.createLoginLink
throws error when executed in Deno environment.
To Reproduce
- Create index.ts file
- Add code
- Run via Deno
- Get error
Expected behavior
Request to execute successfully
Code snippets
// errors
const loginLink = await stripe.accounts.createLoginLink('acct_1LZWJGPPxRBiNZOx')
// works fine
const loginLink = await fetch(
`https://api.stripe.com/v1/accounts/${'acct_1LZWJGPPxRBiNZOx'}/login_links`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${Deno.env.get('STRIPE_API_KEY')}`,
},
}
).then((res) => res.json())
OS
macOS 11.06.1
Node version
Deno version: { deno: “1.20.3”, v8: “10.0.139.6”, typescript: “4.6.2” }
Library version
https://esm.sh/stripe@9.6.0?target=deno&no-check
API version
2020-08-27
Additional context
Related discussion on StripeDev Discord
Potentially related to https://github.com/stripe/stripe-node/issues/954 ?
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Invalid JSON from Stripe - Stack Overflow
Trying to use Stripe with Parse via a "Cloud Function". I made a couple of charges as of yesterday but now it stopped...
Read more >How to Fix SyntaxError: Unexpected token < in JSON at ...
Usually this error is caused when your server returns HTML (which typically begins with <DOCTYPE html> or <html> ) instead of JSON. Valid...
Read more >Stripe API Redirect to Checkout Not Working Reactjs + Nextjs
Project: Small eCommerce site using Stripe API for payments. ... SyntaxError: Unexpected token 'I', "Invalid re"... is not valid JSON.
Read more >Edge Functions Quickstart - Supabase
If you receive an error Invalid JWT , find the ANON_KEY of your project in the Dashboard under Settings > API . After...
Read more >JSON Schema Store
JSON Schemas for common JSON file formats. ... Public API for JSON Schemas The JSON API contains a list of JSON Schema files...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The root cause issue here is Deno injects its own Content-Length header despite
stripe-node
providing a value for it, so the end request has this header twice and nginx returns a 400. I’ve filed https://github.com/denoland/deno/issues/15545 on the Deno side for this.I’ll investigate to see if we can fix this from the Stripe side in the interim.
Hi @thorwebdev - thanks for the patience here!
I’ve released the fix under stripe-node@10.4.0-beta.1 . It now works for me. Could you try it out with your code just to double check, and if all works, I’ll release it to the main stable channel?
You can try this out using:
Thanks!