-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathcurrencies.js
44 lines (34 loc) · 1.02 KB
/
currencies.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import environment from '../configuration/environment';
import currencies from '../mock/currencies';
const limit = 100 ,
api = {
domain : 'https://api.coinmarketcap.com' ,
path :'/v1/ticker/' ,
params : {
limit : 'limit=' ,
currency : 'convert='
} ,
headers : {
Accept : 'application/json' ,
headers : {
'Content-Type' : 'application/json'
}
}
};
export default {
get : async function ( currency ) {
const url = api.domain + api.path + '?' + api.params.limit + limit + '&' + api.params.currency + currency;
return environment.data.mock ? currencies : fetch ( url , {
...api.headers ,
method : 'GET'
});
} ,
limit : limit ,
stream : async function ( currency ) {
const url = api.domain + api.path + '?' + api.params.limit + '0&' + api.params.currency + currency;
return environment.data.mock ? currencies : fetch ( url , {
...api.headers ,
method : 'GET'
});
}
};