(url)
| 9 | } |
| 10 | |
| 11 | function fetchJSON (url) { |
| 12 | if (apiKey !== '') { |
| 13 | if (url.indexOf('?') > -1) { |
| 14 | url += '&api_key=' |
| 15 | } else { |
| 16 | url += '?api_key=' |
| 17 | } |
| 18 | url += apiKey |
| 19 | } |
| 20 | return fetch(url) |
| 21 | .then(res => { |
| 22 | if (!res.ok) { |
| 23 | throw new Error(`${res.status} ${res.statusText}`) |
| 24 | } |
| 25 | return res.json() |
| 26 | }) |
| 27 | .then(body => { |
| 28 | if (body.Response === 'Error') throw body.Message |
| 29 | return body |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | function coinList () { |
| 34 | const url = `${baseUrl}all/coinlist` |
no outgoing calls
no test coverage detected