Before performing any operations, you must connect to MindsDB. By default, all operations will go through MindsDB Cloud REST APIs, but you can use a self-hosted version of MindsDB as well.
Here is how to connect to your local MindsDB server:
import MindsDB from 'mindsdb-js-sdk';// const MindsDB = require("mindsdb-js-sdk").default; // alternative for CommonJS syntaxtry { // No authentication needed for self-hosting await MindsDB.connect({ // alternative for ES6 module syntax: await MindsDB.default.connect({ host: 'http://127.0.0.1:47334' }); console.log('connected');} catch(error) { // Failed to connect to local instance console.log(error);}
Here is how to connect to your local MindsDB server:
import MindsDB from 'mindsdb-js-sdk';// const MindsDB = require("mindsdb-js-sdk").default; // alternative for CommonJS syntaxtry { // No authentication needed for self-hosting await MindsDB.connect({ // alternative for ES6 module syntax: await MindsDB.default.connect({ host: 'http://127.0.0.1:47334' }); console.log('connected');} catch(error) { // Failed to connect to local instance console.log(error);}