steinhq / js-client Goto Github PK
View Code? Open in Web Editor NEWJavaScript client library to interact with the Stein API
License: MIT License
JavaScript client library to interact with the Stein API
License: MIT License
Hi guys,
I have player with Stein lately, it's really cool.
I have built a small project with Gatsby and used Stein+spreadsheet as the database.
It's working well when I used it on the front end, from the react app. I now want to include the call from a lambda function to make the app secure, but it seems I really can't read from a store inside my lambda function. I really do not understand why. Here is the code and the errors I get:
// lambda function js
import SteinStore from "stein-js-client"
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/PRIVATE"
);
export function handler(event, context, callback) {
console.log("queryStringParameters", event.queryStringParameters)
console.log(store);
store.read("questions").then(result => {
console.log("result:");
console.log(result);
})
}
Here is the log from the console:
Request from ::ffff:127.0.0.1: GET /questionList
queryStringParameters [Object: null prototype] {}
u {
url:
'https://api.steinhq.com/v1/storages/PRIVATE/' }
(node:4144) UnhandledPromiseRejectionWarning: TypeError: r(...) is not a function
at e.exports.global.fetch (/Users/matt/Documents/htdocs/gatsbydynamic/lambda/questionList.js:1:1625)
at Promise (/Users/matt/Documents/htdocs/gatsbydynamic/lambda/questionList.js:1:21063)
at new Promise (<anonymous>)
at e.exports (/Users/matt/Documents/htdocs/gatsbydynamic/lambda/questionList.js:1:21043)
at u.read (/Users/matt/Documents/htdocs/gatsbydynamic/lambda/questionList.js:1:20213)
at Object.s [as handler] (/Users/matt/Documents/htdocs/gatsbydynamic/lambda/questionList.js:1:22728)
at /Users/matt/Documents/htdocs/gatsbydynamic/node_modules/netlify-lambda/lib/serve.js:143:27
at Layer.handle [as handle_request] (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/route.js:137:13)
at next (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/route.js:131:14)
at next (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/route.js:131:14)
at next (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/route.js:131:14)
at next (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/route.js:131:14)
at next (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/route.js:131:14)
at next (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/route.js:131:14)
at Route.dispatch (/Users/matt/Documents/htdocs/gatsbydynamic/node_modules/express/lib/router/route.js:112:3)
(node:4144) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 15)
Any clue ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.