Skip to main content
Question

Error: "expected token ..." when trying to use the notion client npm package inside a figma plugin

  • September 12, 2023
  • 3 replies
  • 1343 views

I want to use the notion client sdk inside a Figma plugin. It’s just used to call the Notion api, nothing particularly fancy about it. I get an error when I try to use it.

When I do this in some file:


import { Client, LogLevel } from "@notionhq/client";
export const notion = new Client({"<my credentials>"});

And then import the client in another file

import { notion } from "./someFile";
console.log(notion);

I get the following error:

Syntax error on line 372: Unexpected token ...
            ...authorizationHeader,

I probably have ran into this issue before in my life but don’t remember what it was. Probably some incompatibility issue. How do you generally debug these things? I have limited information on where to even look.

Thanks in advance if you have any ideas.

This topic has been closed for replies.

3 replies

Gleb
  • Power Member
  • 4708 replies
  • September 12, 2023

You put … in place of the most important word. Which token? 😃

Could be an issue with bundling. What compiler/bundler are you using and what’s the config? Make sure you are inlining everything into a single .js file.


  • Author
  • 4 replies
  • September 12, 2023

I think it’s literallry “…” if I understand correctly ;).

Syntax error on line 372: Unexpected token ...
            ...authorizationHeader,

But i use the spread operator in my code and it is not an issue.

Thanks for helping!


Gleb
  • Power Member
  • 4708 replies
  • September 12, 2023

Ah, sorry, I didn’t realize it’s a spread operator. In this case it’s likely something before ... that causes an issue. Maybe an open bracket that expects something different after. You can try to experiment with build targets in your compiler, e.g. try something like es2016 or earlier.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings