UNPKG

@biopolymer-elements/bio-link

Version:

Creates links to 3rd party public databases

34 lines (32 loc) 913 B
/** * This class is responsible for importing data into the database. * * <code> * let importer = new DataImporter(); * importer.importJsonData('pubmed', 1234) * .then(response => { * let data = response.json(); * ... persist the data * }) * .catch(error => { * console.log(error); * ... handle the error * }); * </code> */ class DataImporter extends URLBuilder { constructor() { super(); } /** * This method is responsible for fetching the data for a particular database record. * Simply call the method, and add 'then' * @param {String} databaseName The name of the database * @param {String} id The ID of the database record * @returns {Object} the JSON object generated by the fetch object. */ importJsonData(databaseName, id) { let url = super.buildRestUrl(databaseName, id); return fetch(url); } }