Skip to main content

Unable to add ‘await’. Get the editor error Missing “;” before statement. on line 16.
Without the await the code executes but the binary file arrives corrupted due to truncating. Why cant I add the await syntax to line 16?

const encodedToken = Buffer.from(bundle.authData.api_key, 'ascii').toString('base64');

const fileRequest = z.request({
url: 'https://app.useanvil.com/api/v1/generate-pdf',
raw: true,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${encodedToken}`
},
body: {
'data':bundle.inputData.template
}
});

const file = await z.stashFile(fileRequest);

return {file};

 

Can you share where you’re implementing this code? stashfile is promise-based, but maybe the answer is in the context of what you’re up to. As an aside, you will probably need to await the z.request call too when the time comes. 


I’m implementing this code as an Action on the Developer platform. I try to add the ‘await’ as seen above on line 16, but get a editor error Missing “;” before statement. But all relevant documentation states I should add an ‘await’, so I’m am confused as to why the Developer platform code editor is throwing this error. The await seems necessary as the binary file requested gets truncated/corrupted without it.


In order to help I need a little more context. Maybe you could record a loom of the situation and triggering the error? I don’t know if you’re using the CLI, the developer interface, or where the code is getting applied. Showing in a vid can be a really fast way to deliver a lot of information without having to explain a lot. 


Hi @amarunda , 

It sounds like you’re using the developer platform’s UI, correct? If so, this might be related to a bug in the linter used by that code editor. 

Have you tried testing the code regardless of the missing semicolon error? Barring actual issues, if linting is responsible, the code should still execute.

If the code works despite the error, you can hide the error using the linter’s ignore directive.

I hope that helps, but please feel free to reach out Platform Support team with any questions: https://developer.zapier.com/contact


Reply