util-fetch

Methods

(inner) fetchData(url, config) → {Promise}

Fetch data from the URL passsed
Parameters:
Name Type Description
url string URL from data needs to be fetched
config object define callbacks for success and error
Properties
Name Type Attributes Description
successCallback object <optional>
success callback to be called when call returns 200 status code and data
errorCallback object <optional>
= error callback to be called when call returns status code other than 200 or something else breaks
Since:
  • 0.0.2
Source:
Example
fetchData('https://google.com', {
  successCallback: (data) { console.log('Got data as', data)},
  errorCallback: (err) { console.log('Something went wrong', err) }
});