mirror of
https://github.com/fullstack-cash/fullstack-gatsby-theme-bch-wallet.git
synced 2026-09-21 16:52:06 -07:00
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
|
|
/*
|
|
This library It's used to download a more easily maintained list of Back End servers.
|
|
*/
|
|
|
|
const axios = require('axios')
|
|
|
|
class Gist {
|
|
constructor () {
|
|
this.axios = axios
|
|
}
|
|
|
|
// Retrieve a JSON file from a GitHub Gist
|
|
async getServerList () {
|
|
try {
|
|
// https://gist.github.com/christroutner/e818ecdaed6c35075bfc0751bf222258
|
|
const gistUrl =
|
|
'https://api.github.com/gists/63c5513782181f8b8ea3eb89f7cadeb6'
|
|
|
|
// Retrieve the gist from github.com.
|
|
const result = await this.axios.get(gistUrl)
|
|
// console.log('result.data: ', result.data)
|
|
|
|
// Get the current content of the gist.
|
|
const content = result.data.files['psf-consumer-apis.json'].content
|
|
// console.log('content: ', content)
|
|
|
|
// Parse the JSON string into an Object.
|
|
const object = JSON.parse(content)
|
|
// console.log('object: ', object)
|
|
|
|
return object.consumerApis
|
|
} catch (err) {
|
|
console.error('Error in getCRList()')
|
|
throw err
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Gist
|