From 2497b46494c0405bdbb70e5f0bd08b08a688ae88 Mon Sep 17 00:00:00 2001 From: Subeom Choi Date: Fri, 19 Jan 2024 17:48:21 +0900 Subject: [PATCH] fix: solve issue that can not encode json --- Source/Network/Implement/Client/JSONClient.swift | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Source/Network/Implement/Client/JSONClient.swift b/Source/Network/Implement/Client/JSONClient.swift index d90b8ca..91cb573 100644 --- a/Source/Network/Implement/Client/JSONClient.swift +++ b/Source/Network/Implement/Client/JSONClient.swift @@ -14,26 +14,18 @@ import SabyTime public final class JSONClient: Client { let client: DataClient - let encoder: JSONEncoder - let decoder: JSONDecoder init( - client: DataClient, - encoder: JSONEncoder, - decoder: JSONDecoder + client: DataClient ) { self.client = client - self.encoder = encoder - self.decoder = decoder } } extension JSONClient { public convenience init(optionBlock: (inout URLSessionConfiguration) -> Void = { _ in }) { let client = DataClient(optionBlock: optionBlock) - let encoder = JSONEncoder() - let decoder = JSONDecoder() - self.init(client: client, encoder: encoder, decoder: decoder) + self.init(client: client) } } @@ -46,7 +38,7 @@ extension JSONClient { timeout: Interval? = nil, optionBlock: (inout URLRequest) -> Void = { _ in } ) -> Promise, Error> { - guard let body = try? self.encoder.encode(body) else { + guard let body = try? body?.datafy() else { return Promise.rejected(JSONClientError.bodyIsNotEncodable) }