Skip to content

Getting started does not work #262

Closed
@curquiza

Description

@curquiza

I tried:

$ yarn init
$ yarn add meilisearch

In test.js

const MeiliSearch = require('meilisearch')

const meili = new MeiliSearch({ host: 'http://127.0.0.1:7700' })
const index = await meili.createIndex({ uid: 'indexUID' })

Then:

$ node test.js

I get:

const index = await meili.createIndex({ uid: 'indexUID' })

SyntaxError: await is only valid in async function
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

(Same error if I try with getIndex)

Can we do a getting started directly working for the JS beginners like me? 😇

Version

meilisearch: v0.9.0
node: v10.18.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions