How do I add a promise to the Cals constructor?
-
Tell me.
How to add fetch's answer to the constructor. With the possibility of withdrawal?
I teach classes.
Or how to output fetch c class correctly.
class Board { constructor() { //this.data = result getReferral } getReferral(url) { return fetch(url) .then(response => response.json()) .then(data => console.data(data)) } } const ruler = new Board(); const referral = ruler.getReferral(); console.log(ruler.data);
JavaScript Declan Kirk, May 7, 2019
0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!