A
A
Alina Ananyiva2016-06-04 15:00:46
JavaScript
Alina Ananyiva, 2016-06-04 15:00:46

How to run js promise on local machine?

Good afternoon. I understood promises from the lessons of Ilya Kantor, articles on Habré, the Plunker sandbox. The problem is that none of the sandbox promise code works on my local machine. The situation is aggravated by the fact that I do not understand how all sorts of collectors work.
Installed bower with npm ---> npm install es6-promise -g (installed) ---> bower install es6-promise --save (No .json file to save to, use bower init to create one) --- > bower init (Result: fill in name, keywords, license, etc.) ---> Created a .json with the content I entered. Many other files have also been created in the bower_components folder. I don't know what to do with all of them and why code with promises from other folders doesn't work if npm install es6-promise -g. Where does it actually need to be in order to work?
Everyone else (Kantor, Habr) writes about some polyfills, but I don’t understand why they are and what they do when there is an es6-promise ... which, for some reason, does not work.
Help, please, to understand.
PS Promises support cross-domain requests?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
timfcsm, 2016-06-04
@amol

firstly, show the code,
I hope you are not in IE trying to run these examples? promises are supported in all normal browsers caniuse.com/#feat=promises es6
-promise which you set, this is the same polyfill, should be in the bower_components/es6-promise folder, you just need to connect the es6-promise.js file to the page from there ... but again, for all browsers except IE it is not needed

A
Anton, 2016-06-05
@SPAHI4

A polyfill is a file that provides browser support for an unsupported property, specifically here - promises. If you run through supported browsers ( caniuse.com/#feat=promises) then you don't need it. But in production, as a rule, you need to connect it. If you don’t go deep into assemblers and loaders, then it’s enough to connect it with a regular tag

<script src="bower_components/es6-promise/es6-promise.min.js"></script>

Well, what (nothing to do with) here cross-domain requests, have already written

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question