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

safe-global / safe-core-sdk / 15781738432

20 Jun 2025 02:56PM UTC coverage: 78.249% (-0.04%) from 78.287%
15781738432

Pull #1231

github

web-flow
Merge 951f3c2e2 into aea722aa6
Pull Request #1231: Prepare release

261 of 409 branches covered (63.81%)

Branch coverage included in aggregate %.

54 of 58 new or added lines in 5 files covered. (93.1%)

1 existing line in 1 file now uncovered.

919 of 1099 relevant lines covered (83.62%)

4.8 hits per line

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

15.22
/packages/api-kit/src/utils/httpRequests.ts
1
export enum HttpMethod {
1✔
2
  Get = 'get',
1✔
3
  Post = 'post',
1✔
4
  Delete = 'delete'
1✔
5
}
6

7
export interface HttpRequest {
8
  url: string
9
  method: HttpMethod
10
  body?: any
11
}
12

13
export async function sendRequest<T>(
1✔
14
  { url, method, body }: HttpRequest,
15
  apiKey?: string
16
): Promise<T> {
17
  const fetch = await (typeof window === 'undefined'
×
18
    ? import('node-fetch').then((m) => m.default)
×
19
    : Promise.resolve(window.fetch))
20

NEW
21
  const headers: Record<string, string> = {
×
22
    Accept: 'application/json',
23
    'Content-Type': 'application/json'
24
  }
25

NEW
26
  if (apiKey) {
×
NEW
27
    headers['Authorization'] = `Bearer ${apiKey}`
×
28
  }
29

UNCOV
30
  const response = await fetch(url, {
×
31
    method,
32
    headers,
33
    body: JSON.stringify(body)
34
  })
35

36
  let jsonResponse: any
37
  try {
×
38
    jsonResponse = await response.json()
×
39
  } catch (error) {
40
    if (!response.ok) {
×
41
      throw new Error(response.statusText)
×
42
    }
43
  }
44

45
  if (response.ok) {
×
46
    return jsonResponse as T
×
47
  }
48
  if (jsonResponse.data) {
×
49
    throw new Error(jsonResponse.data)
×
50
  }
51
  if (jsonResponse.detail) {
×
52
    throw new Error(jsonResponse.detail)
×
53
  }
54
  if (jsonResponse.message) {
×
55
    throw new Error(jsonResponse.message)
×
56
  }
57
  if (jsonResponse.nonFieldErrors) {
×
58
    throw new Error(jsonResponse.nonFieldErrors)
×
59
  }
60
  if (jsonResponse.delegate) {
×
61
    throw new Error(jsonResponse.delegate)
×
62
  }
63
  if (jsonResponse.safe) {
×
64
    throw new Error(jsonResponse.safe)
×
65
  }
66
  if (jsonResponse.delegator) {
×
67
    throw new Error(jsonResponse.delegator)
×
68
  }
69
  throw new Error(response.statusText)
×
70
}
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