20 lines
		
	
	
	
		
			419 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
	
		
			419 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| class GetJson {
 | |
|   constructor(url) {
 | |
|     this.url = url;
 | |
|     this.items = [];
 | |
|     this.item = undefined;
 | |
|   }
 | |
| 
 | |
|   async theData() {
 | |
|     const resp = await fetch(this.url);
 | |
|     console.assert(resp.status == 200, "failed to get it");
 | |
|     this.items = await resp.json();
 | |
|     return this.items;
 | |
|   }
 | |
| 
 | |
|   async oneThing() {
 | |
|     this.item = await this.theData();
 | |
|     console.log("ITEMS", this.items);
 | |
|     return this.item;
 | |
|   }
 | |
| }
 | 
