Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get module to work from browser #42

Closed
HumanistSerif opened this issue Oct 17, 2017 · 3 comments
Closed

Unable to get module to work from browser #42

HumanistSerif opened this issue Oct 17, 2017 · 3 comments

Comments

@HumanistSerif
Copy link

This might be more of a request than an issue.

Does this module work from within the browser? I don't have a NodeJS app and I'm trying to execute this script from within the browser. I'm using Browserify to require and bundle the necessary modules.

var AWS = require('aws-sdk');
var creds = new AWS.Credentials('AKID','Security');
var  es = require('elasticsearch').Client({
    host: 'https://hostname.us-east-1.es.amazonaws.com/',
    connectionClass: require('http-aws-es'),
    amazonES: {
      region: 'us-east-1',
      credentials: creds
    }
  });

es.cluster.health({},function(err,resp,status) {
    console.log("-- Client Health --",resp);
});

I get the following error in the console:

AWS Credentials error: No credentials to load

Is it possible to adapt this awesome module to work from within the browser?

@TheDeveloper
Copy link
Owner

Hi @HumanistSerif

This should work fine in the browser. That config you're using there is for an older version of this module. Perhaps try upgrading and taking a look at the readme for configuring the latest version?

@TheDeveloper
Copy link
Owner

Actually, I take that back. This probably won't play nice with browsers at the moment because the connector tries to use AWS.NodeHTTPClient which will not be available in a browserified aws-sdk.

It should be possible to add in support for running in browsers. We would need to use the AWS.XHRClient instead.

@TheDeveloper
Copy link
Owner

@HumanistSerif just pushed 4.0.0 for ability to run in browsers. Please re-open this issue if any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants