fetchData
fetchData(url: string, responseType: string) → {Promise}
Fetches data from the specified URL.
fetchData('https://api.example.com/data', 'json')
.then(data => {
// Handle the fetched JSON data
})
.catch(error => {
// Handle the error
});
Name | Type | Description |
---|---|---|
url | string |
The URL to fetch the data from. |
responseType | string |
The type of response expected ('json', 'text', 'blob', 'arrayBuffer'). |
Type | Description |
---|---|
Promise |
A promise that resolves with the fetched data or rejects with an error. |