Requests WIP

This commit is contained in:
Wilhelm Oks
2024-12-20 16:19:17 +01:00
parent 793db8bac9
commit ce3c96b887
3 changed files with 230 additions and 6 deletions
@@ -161,4 +161,10 @@ public struct Request {
let outData = try await requestData(urlRequest: urlRequest, apiError: apiError).data
return try decoder.decode(Out.self, from: outData)
}
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
return try decoder.decode(Out.self, from: outData)
}
}