- Local MindsDB
- Own Axios Instance
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 syntax
try {
// 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);
}
import MindsDB from 'mindsdb-js-sdk';
// const MindsDB = require("mindsdb-js-sdk").default; // alternative for CommonJS syntax
import axios from 'axios';
// Use 'host' option in MindsDB.connect to specify base URL override
const customAxios = axios.create({
timeout: 1000,
});
try {
await MindsDB.connect({
user: mindsdbuser@gmail.com,
password: mypassword,
httpClient: customAxios
});
console.log('connected');
} catch(error) {
// Failed to authenticate
console.log(error);
}
await must be wrapped in an async function, like this:(async() => {
try {
// No authentication needed for self-hosting
await MindsDB.connect({
host: 'http://127.0.0.1:47334'
});
console.log('connected');
} catch(error) {
// Failed to connect to local instance
console.log(error);
}
})();
Was this page helpful?