loadData = () => {
var options = {
uri: 'http://fake-domen.com/...',
headers: {
'User-Agent': 'Request-Promise'
},
json: true // Automatically parses the JSON string in the response
};
return rp(options)
.then(function (repos) {
console.log(repos, 'repos');
return repos
})
.catch(function (err) {
// API call failed...
});
}
const func = require('./func);
func()
.then()
class Service {}
export.module = new Service();
class Service {}
let service = () => {
let instance
function init() {
let opt = new Service()
return opt
}
return {
getInstance: function () {
if (!instance) {
instance = init()
}
return instance
}
}
}
module.export = service().getInstance()