Skip to content

Instantly share code, notes, and snippets.

@davidgomes
Created April 9, 2023 15:56
Show Gist options
  • Save davidgomes/d71d0535ba42410fc736314d43147b00 to your computer and use it in GitHub Desktop.
Save davidgomes/d71d0535ba42410fc736314d43147b00 to your computer and use it in GitHub Desktop.
var SingleStoreClient = require('@singlestore/http-client');
var instance = SingleStoreClient.ApiClient.instance;
var BasicAuth = instance.authentications['BasicAuth'];
BasicAuth.username = process.env.SINGLESTORE_WORKSPACE_USERNAME;
BasicAuth.password = process.env.SINGLESTORE_WORKSPACE_PASSWORD;
instance.basePath = 'https://' + process.env.SINGLESTORE_WORKSPACE_HOST;
// Get the API handle.
var api = new SingleStoreClient.HttpApi();
export default function handler(req, res) {
api.rows(
{ queryInput: { database: 'mydatabase', sql: 'SELECT * FROM purchases LIMIT 200;' } }
).then(dbResponse => {
res.send(dbResponse.results[0].rows);
}).catch(err => {
res.send(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment