PHP Classes

File: assets/js/lib/FetchData.js

Recommend this page to a friend!
  Classes of Rodrigo Faustino   Simple SPA   assets/js/lib/FetchData.js   Download  
File: assets/js/lib/FetchData.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Simple SPA
Demonstrates single page applications
Author: By
Last change:
Date: 17 days ago
Size: 481 bytes
 

Contents

Class file image Download
class FetchData { constructor(url) { this.url = url; } async getJson() { try { const response = await fetch(this.url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data; } catch (error) { console.error('Could not get data:', error); } } } export default FetchData;