Created
February 2, 2016 17:43
-
-
Save MeoBeoI/b6db554c87fa7c13e227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getListFilms() | |
.then(getListGais) | |
.then(guiListFilmChoListGai) | |
.then(traVeKetQuaCuoiCungNe) | |
.catch(err){ | |
console.log('Chi phai xu li err 1 lan ne') | |
} | |
function getListFilms(){ | |
return new Promise(function(fulfill, reject) { | |
request('http://getListFilms.com', function(err, listFilms){ | |
if (err) reject(err) | |
fulfill({ | |
listFilms : listFilms | |
}) | |
} | |
}) | |
} | |
function getListGais(data){ | |
// Trong data co listFilms ne | |
// Nho truyen lai cho doi sau su dung nua | |
return new Promise(function(fulfill, reject) { | |
request('http://getListGai.net', function(err, listGais){ | |
if (err) reject(err) | |
fulfill({ | |
listFilms : data.listFilms, | |
listGais : listGais | |
}) | |
} | |
}) | |
} | |
function guiListFilmChoListGai(data){ | |
// Trong data co listGais va listFilms ne | |
// Su dung de thuc hien request tiep theo | |
return new Promise(function(fulfill, reject) { | |
request('http://guiListFilmChoListGa', function(err, listGaiOkDiXemFilmDeBanLuaChon){ | |
if (err) reject(err) | |
fulfill({ | |
listGaiOkDiXemFilmDeBanLuaChon : listGaiOkDiXemFilmDeBanLuaChon | |
}) | |
} | |
}) | |
} | |
function traVeKetQuaCuoiCungNe (listGaiOkDiXemFilmDeBanLuaChon) { | |
if (listGaiOkDiXemFilmDeBanLuaChon.length == 0) { | |
// Nhu cai bui trau | |
} else { | |
return listGaiOkDiXemFilmDeBanLuaChon; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment