feat: merge

This commit is contained in:
ding 2021-11-21 15:10:25 +08:00
commit ecf7fd1913
2 changed files with 28 additions and 0 deletions

View File

@ -12,6 +12,25 @@ export default class OsmosAPI {
return fetch(`${this.host}${url}`).then(res => res.json()) return fetch(`${this.host}${url}`).then(res => res.json())
} }
async getOHCL4Pairs(from, to) {
this.exe_time = ''
const ohlc = await Promise.all(
[fetch(`https://api.coingecko.com/api/v3/coins/${from}/ohlc?vs_currency=usd&days=7`).then(res => res.json()),
fetch(`https://api.coingecko.com/api/v3/coins/${to}/ohlc?vs_currency=usd&days=7`).then(res => res.json())],
)
const output = []
ohlc[0].forEach((e, i) => {
console.log(e, i, ohlc[1][i])
const price = [e[0]]
for (let j = 1; j <= 4; j += 1) {
price.push(e[j] / ohlc[1][i][j])
}
output.push(price)
})
return output
}
// Custom Module // Custom Module
async getPools() { async getPools() {
return this.get('/osmosis/gamm/v1beta1/pools?pagination.limit=700') return this.get('/osmosis/gamm/v1beta1/pools?pagination.limit=700')

View File

@ -29,6 +29,15 @@ export default {
Ticker, Ticker,
Place, Place,
}, },
created() {
// $http.osmosis
this.$http.osmosis.getOHCL4Pairs('cosmos', 'osmosis').then(data => {
console.log(data)
})
// this.$http.osmosis.getPools().then(res => {
// this.pools = res
// })
},
} }
</script> </script>