You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.4 KiB
38 lines
1.4 KiB
8 years ago
|
import axios from 'axios'
|
||
|
|
||
7 years ago
|
// When running in development/hot mode we load the renderer js code via webpack dev server, and it is from there that
|
||
|
// we ultimately initate requests to these remote resources. The end result is that the electron browser window makes a
|
||
|
// request to localhost (to webpack dev server), which in turn makes a request to the remote resource. If the remote
|
||
|
// resource in question has a restrictive `Access-Control-Allow-Origin` header, this may cause the electron browser
|
||
|
// window to not allow loading the remote content.
|
||
|
//
|
||
|
// See https://enable-cors.org/
|
||
|
//
|
||
|
// In order to mitigate the CORS issue, we instead access these remote resources through a local proxy that we have
|
||
|
// defined on the webpack dev server.
|
||
|
const scheme = process.env.HOT ? '/proxy/' : 'https://'
|
||
|
|
||
7 years ago
|
export function requestTicker(id) {
|
||
7 years ago
|
const BASE_URL = `${scheme}api.coinmarketcap.com/v1/ticker/${id}`
|
||
8 years ago
|
return axios({
|
||
|
method: 'get',
|
||
|
url: BASE_URL
|
||
7 years ago
|
}).then(response => response.data)
|
||
8 years ago
|
}
|
||
7 years ago
|
|
||
|
export function requestTickers(ids) {
|
||
7 years ago
|
return axios
|
||
|
.all(ids.map(id => requestTicker(id)))
|
||
7 years ago
|
.then(
|
||
|
axios.spread((btcTicker, ltcTicker) => ({ btcTicker: btcTicker[0], ltcTicker: ltcTicker[0] }))
|
||
|
)
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
7 years ago
|
export function requestSuggestedNodes() {
|
||
7 years ago
|
const BASE_URL = `${scheme}zap.jackmallers.com/suggested-peers`
|
||
7 years ago
|
return axios({
|
||
|
method: 'get',
|
||
|
url: BASE_URL
|
||
7 years ago
|
}).then(response => response.data)
|
||
7 years ago
|
}
|