feat: merge
This commit is contained in:
commit
ecf7fd1913
@ -12,6 +12,25 @@ export default class OsmosAPI {
|
||||
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
|
||||
async getPools() {
|
||||
return this.get('/osmosis/gamm/v1beta1/pools?pagination.limit=700')
|
||||
|
@ -29,6 +29,15 @@ export default {
|
||||
Ticker,
|
||||
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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user