Programming Web Technology

Convert jQuery ajax function into promise (in ES6)

If you happens to want to convert jQuery’s ajax function into promise style using ES6 promise. Here is an example for you:


Then you can use ajaxPostPromise in this way:


That’s it!

You can apply the same principle in converting other callback-style library into promise!

p.s. If you are looking for native and promise way to call your API, you may also check out fetch.