question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EXCEPTION: Promise is not a constructor in v12.0.0-rc5

See original GitHub issue

I am trying to get this working with an angular2 application. I am importing this (elasticsearch.js) into my component and then:

var connectionString = 'xyz';
this._client = new elasticsearch.Client({ host: connectionString, log: 'trace' });

ngOnInit() {
    console.log('NGINIT');
    /*this._client.search({
      index: 'twitter',
      type: 'tweets',
      body: {
        query: {
          match: {
            body: 'elasticsearch'
          }
        }
      }
    }).then(function (resp) {
      var hits = resp.hits.hits;
    }, function (err) {
      console.trace(err.message);
    });
*/

  }

so in my console I get:

DEBUG: 2016-10-02T12:09:56Z starting request { “method”: “POST”, “path”: “/plugins/document/_search”, “body”: { “query”: { “query_string”: { “query”: “Bluetooth” } } }, “query”: {} }

and then when I uncomment the this._client.search({ section, I get:

EXCEPTION: Promise is not a constructor

client.ping({ ...})

works as expected. and the issue goes away if I use v.11.0.1 rather than v.12.0.0-rc5

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kmulveycommented, Dec 14, 2016

totally works now, thanks

0reactions
spalgercommented, Dec 14, 2016

Apologies, I accidentally ignored the promise polyfill in the vanilla browser build. Fixed in 12.1.3, which I just published.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise is not a constructor - javascript - Stack Overflow
With var Promise you declare a local variable in your scope. It is initialised with undefined and shadows the global Promise constructor.
Read more >
Promise.resolve is not a constructor Error in JavaScript
The "Promise.resolve is not a constructor" error occurs when we try to use the `Promise.resolve()` method with the `new` operator. The `Promise.resolve()` ...
Read more >
Promise() constructor - JavaScript - MDN Web Docs
The Promise() constructor is primarily used to wrap functions that do not already support promises.
Read more >
Uncaught (in promise) TypeError: {......} is not a constructor ...
Describe the bug I'm using vanilla ts project with a very basic structure here I've imported the ...
Read more >
Promises: Ember.RSVP is not a constructor - Learning Team
I am experimenting with Promises and trying to adapt a javascript Promise example I found to Ember. I'm getting this error in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found