Requests done

This commit is contained in:
Wilhelm Oks
2024-12-20 19:52:21 +01:00
parent 689f75483d
commit ad1557d96f
2 changed files with 141 additions and 3 deletions
@@ -162,6 +162,11 @@ public struct Request {
return try decoder.decode(Out.self, from: outData)
}
public func requestJson<ApiError: Decodable & Sendable>(config: Config, data: Data, apiError: ApiError.Type = EmptyError.self) async throws {
let urlRequest = makeURLRequest(config: config, body: data)
try await requestData(urlRequest: urlRequest, apiError: apiError).data
}
public func requestJson<Out: Decodable, ApiError: Decodable & Sendable>(config: Config, data: Data, apiError: ApiError.Type = EmptyError.self) async throws -> Out {
let urlRequest = makeURLRequest(config: config, body: data)
let outData = try await requestData(urlRequest: urlRequest, apiError: apiError).data