hasura / js-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught (in promise) TypeError: r is not a function

FlameFractal opened this issue · comments

@FlameFractal

  1. onSuccess and onError are functions that you should define.
  2. A } is missing after the args brace is closed.

Option 1

Use lambdas or anonymous functions directly for handling success/error.

hasura.data.query({
  type: 'select',
  args: {
    table: 'article',
    columns: ['*']
  }},
  (data) => { console.log(data); },
  (error) => { console.log(error); }
);

Option 2:

Use predefined functions

function mySuccessHandler (data) {
  console.log(data);
}

function myErrorHandler (e) {
  console.log(e);
}

hasura.data.query({
  type: 'select',
  args: {
    table: 'article',
    columns: ['*']
  }},
  mySuccessHandler,
  myErrorHandler
);

@coco98 I think the } is missing in the docs as well.

@jaisontj Fixed!
@FlameFractal Did this work for you?