skygear-SDK-JS icon indicating copy to clipboard operation
skygear-SDK-JS copied to clipboard

Connecting to myapp.skygeario.com if endPoint in skygear.config is undefined

Open limouren opened this issue 7 years ago • 0 comments

Consider this situation

// config.js
{
  skygearHost: 'http://localhost:3000/'
}
// index.js
import skygear from 'skygear';

import config from './config';

skygear.config({
  endPoint: config.skygearhost,
}).then(() => {
  console.log('Success!');  // Success!
})
// some very deep file
import skygear from 'skygear';

skygear.lambda('mylambda').then(result => {}, error => {
    console.log('error =', error);
})

What I am getting in console:

error = {
  status: 404,
  error: {
    code: 117,
    message: "route unmatched",
    name: "UndefinedOperation"
  }
}

And it surprises me a lot because my local skygear server is NOT running.

The cause of this is that I am having a typo during skygear.config(skygearhost instead of skygearHost). So I am actually calling skygear.config({endPoint: undefined}), which got accepted and used the default settings from the gulp script. I use the skygear package from npm.

Excepted Behaviors

  1. Return a failure in skygear.config if required parameters are not supplied.
  2. Return failed promise in remote methods

limouren avatar Dec 05 '17 09:12 limouren