(url)
| 2 | |
| 3 | // https://github.com/github/fetch (MIT) |
| 4 | export const get = (url) => { |
| 5 | return new Promise((resolve, reject) => { |
| 6 | var xhr = new XMLHttpRequest() |
| 7 | |
| 8 | xhr.onload = () => { |
| 9 | const body = 'response' in xhr ? xhr.response : xhr.responseText |
| 10 | |
| 11 | if (xhr.status >= 200 && xhr.status < 300) { |
| 12 | resolve(body, xhr) |
| 13 | } else { |
| 14 | reject(xhr) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | xhr.onerror = xhr.ontimeout = () => { |
| 19 | reject(new TypeError('Network request failed')) |
| 20 | } |
| 21 | |
| 22 | xhr.open('GET', url, true) |
| 23 | |
| 24 | xhr.send() |
| 25 | }) |
| 26 | } |
nothing calls this directly
no outgoing calls
no test coverage detected