• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ibm-cloud-security / appid-clientsdk-js / 8018892406

23 Feb 2024 12:04PM UTC coverage: 93.066%. Remained the same
8018892406

push

github

web-flow
Merge pull request #99 from ibm-cloud-security/abod-akhras-patch-2

Update dry-publish.js to use Node v20

78 of 94 branches covered (82.98%)

Branch coverage included in aggregate %.

177 of 180 relevant lines covered (98.33%)

4.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/RequestHandler.js
1
const fetch = require('node-fetch');
1✔
2
const RequestError = require('./errors/RequestError');
1✔
3
class RequestHandler {
4
        async request(url, options) {
5
                let response, text;
6
                try {
6✔
7
                        response = await fetch(url, options);
6✔
8
                        text = await response.text();
5✔
9
                } catch (e) {
10
                        throw new RequestError(`Failed to fetch ${url}. ${e}`, null, e);
1✔
11
                }
12

13
                if (!response.ok || response.status > 300) {
5✔
14
                        if (text.includes('id token not generated with cloud directory idp')) {
2✔
15
                                throw new RequestError(`${JSON.parse(text).error_description}`, response.status);
1✔
16
                        } else {
17
                                throw new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);
1✔
18
                        }
19
                }
20
                
21
                try {
3✔
22
                        return JSON.parse(text);
3✔
23
                } catch(err) {
24
                        if (text !== '') {
2✔
25
                                return text;
1✔
26
                        }
27
                        throw new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);
1✔
28
                }
29
        };
30
}
31
module.exports = RequestHandler;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc