mirror of
https://github.com/jphong1111/awesome-ios-developer.git
synced 2025-01-03 13:31:09 +07:00
Update JSONParameterEncoder.swift
This commit is contained in:
parent
561bb7d619
commit
21af3d0920
@ -7,8 +7,8 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct JSONParameterEncoder: ParameterEncoder {
|
||||
public func encode(urlRequest: inout URLRequest, with parameters: Parameters) throws {
|
||||
struct JSONParameterEncoder: ParameterEncoder {
|
||||
static func encode(urlRequest: inout URLRequest, with parameters: Parameters) throws {
|
||||
do {
|
||||
let jsonAsData = try JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)
|
||||
urlRequest.httpBody = jsonAsData
|
||||
@ -16,7 +16,7 @@ public struct JSONParameterEncoder: ParameterEncoder {
|
||||
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
}
|
||||
} catch {
|
||||
throw NetworkError.encodingFailed
|
||||
throw AppError.encodingFail
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user