Giter Site home page Giter Site logo

js-client's People

Contributors

shivensinha4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

js-client's Issues

Cannot read from store within a lambda function

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.