Closed MinuraPunchihewa closed 1 year ago
The docs use the ES6 modules syntax import MindsDB from 'mindsdb-js-sdk'
, which does not require you to use MindsDB.default
. If you use CommonJS require...
then you will need to use MindsDB.default
due to how the SDK is bundled.
It could be helpful to mention in the docs if you're using require...
then you need to access the functions MindsDB.default
though. I did that here
Hey @tmichaeldb, Thank you for your response. I am not a JavaScript expert by any means, but I believe this did not work for me using ES6 syntax either.
Can you help me out here?
This is the code I have been working on. I am looking to create a NPM package, https://github.com/MinuraPunchihewa/the-issue-is/tree/feature/github_issue_creator_npm_pkg
This is the project where I came across the other issue we have been discussing as well.
Hey @MinuraPunchihewa, I was trying to use the SDK in a Nuxt3 app (server side) and getting the same error. So how to resolve that?
EDIT:
Just now saw the repo you've linked to. It uses MindsDB.default
everywhere even though the ES6 import syntax is being used. And guess what, it works for my issue as well. Just now tested it, and was able to connect to my local mindsDB docker instance.
Hey @ra-jeev,
Yes, I had to use MindsDB.default
to get it to work.
Moreover, you can't do MindsDB.default
if by any chance you're using Typescript as it starts complaining
"Property 'default' does not exist on type '{ connect: (options: ConnectionOptions) => Promise<void>; SQL: SqlRestApiClient; Databases: DatabasesRestApiClient; Models: ModelsRestApiClient; Projects: ProjectsRestApiClient; Tables: TablesRestApiClient; Views: ViewsRestApiClient; }'."
When using the SDK, I have always been required to use
MindsDB.default.
to execute any sort of operation. Anytime I tried running a command by simply usingMindsDB.
, I have run into errors such as the following,TypeError: MindsDB.connect is not a function
Is this the new syntax that works? If so, should the docs be rewritten as such?