briefly,I will tell you how to convert an existing callback to promise.
We will need to use babel.
For example, let's take a request from npm and convert it to a promise
yarn add babel-plugin-promise --dev
require("babel-polyfill"); import request from "request"; //@promisify<err,res> req __ = request(arg1); console.log(req("http://www.google.com")); req("http://www.google.com") .then(res => console.log(res.body.length)) .catch(err => console.log(err));
let's check
quite quickly
Top comments (0)