Last active
September 27, 2019 07:45
-
-
Save c4software/30947f2a86eb0ab065d26a6ed0edb3e9 to your computer and use it in GitHub Desktop.
DAO et Models d'exemple
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
// À mettre dans un dossier par exemple (models/utilisateur.js) | |
export default class Utilisateur { | |
nom = ""; | |
prenom = ""; | |
constructor(data) { | |
this.nom = data.nom; | |
this.prenom = data.prenom; | |
} | |
} | |
--- | |
// À mettre dans un dossier par exemple (dao/utilisateur.js) | |
export default class UtilisateurDao { | |
static list() { | |
fetch("mon_lien/list")) | |
.then(function (response) { | |
return response.json(); | |
}).then(function (data){ | |
return data.map(it => new Utilisateur(it)) | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment