Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught ReferenceError: Promise is not defined

A Chrome App I've made works perfectly fine for me, but another user gets an error Uncaught ReferenceError: Promise is not defined when starting it up. For some reason it doesn't understand what a Promise is. The code works perfectly fine on my end and I've never gotten that error before, but the user gets it every time. What could be the issue here?

like image 766
Fabis Avatar asked Apr 21 '14 00:04

Fabis


People also ask

How do I fix uncaught ReferenceError is not defined in jQuery?

Answer: Execute Code after jQuery Library has Loaded The most common reason behind the error "Uncaught ReferenceError: $ is not defined" is executing the jQuery code before the jQuery library file has loaded. Therefore make sure that you're executing the jQuery code only after jQuery library file has finished loading.

What is uncaught ReferenceError in JavaScript?

The Javascript ReferenceError occurs when referencing a variable that does not exist or has not yet been initialized in the current scope.

What are JavaScript promises?

A Promise is a JavaScript object that links producing code and consuming code.


2 Answers

The user updated Chrome to the latest version and that apparently fixed it. I don't know how, since his version was from December 2013 and surely Promises worked back then. I don't know. It definitely isn't a problem with the code since I'm running the same exact version the user is running and I've never encountered that error.

But yeah - apparently fixed.

EDIT: Apparently Promises only work since Chrome 32, so yeah that's why the error.

like image 102
Fabis Avatar answered Oct 03 '22 18:10

Fabis


To support IE and older versions of other browsers, you should consider loading a polyfill for the Promise object.

One implementation you can use out of the box with a <script> tag is available here.

like image 41
Florian Ledermann Avatar answered Oct 03 '22 17:10

Florian Ledermann