I am going through Stripes integration steps and have come across an error for my code found in step 2.1 (https://stripe.com/docs/connect/collect-then-transfer-guide#create-an-account-link)
How do I fix this error?
Code:
const stripe = require('stripe')('someID');
const account = await stripe.accounts.create({
type: 'express',
});
Error:
Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.ts(1378)
You can wrap your code for const account inside an async function as your target option doesn't support top level await.
const account = async () => {
await stripe.accounts.create({
type: "express",
});
};
It depends on your code whether you want to return something or you want to perform some other tasks after await.
Incase if you want to use top level await, More about using top level await is on https://stackoverflow.com/a/56590390/9423152