FrontendMasters / fullstack-graphql

370 stars 911 forks source link

Error when importing nanoid function in pet model. "nanoid is not a function" #27

Open RaminMammadzada opened 3 years ago

RaminMammadzada commented 3 years ago

Issue:

It gives the following error when importing nanoid method inside pet.js file.

 "errors": [
    {
      "message": "nanoid is not a function",

The exact location of import:

https://github.com/FrontendMasters/fullstack-graphql/blob/f64d7759898c70360d1db3cf76c659ca352ec722/api/src/db/pet.js#L1

RaminMammadzada commented 3 years ago

Solution:

The nanoid function must be imported as named import as it is given in the documentation:

const { nanoid } = require('nanoid')