Skip to content

Commit

Permalink
Update TokenRequest.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricecarrier7 committed Jul 25, 2024
1 parent 74742fd commit 917ca58
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions Palace/SignInLogic/TokenRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,9 @@ import Foundation
let base64LoginString = loginData.base64EncodedString()
request.addValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")

// do {
// let (data, _) = try await URLSession.shared.data(for: request)
//
// let decoder = JSONDecoder()
// decoder.keyDecodingStrategy = .convertFromSnakeCase
// let tokenResponse = try decoder.decode(TokenResponse.self, from: data)
// return .success(tokenResponse)
// } catch {
// return .failure(error)
// }
do {
let (data, _) = try await URLSession.shared.data(for: request)

// Pretty print the JSON data
if let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []),
let jsonData = try? JSONSerialization.data(withJSONObject: jsonObject, options: [.prettyPrinted]),
let jsonString = String(data: jsonData, encoding: .utf8) {
print("Pretty Printed JSON:\n\(jsonString)")
} else {
print("Failed to pretty print JSON")
}


let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let tokenResponse = try decoder.decode(TokenResponse.self, from: data)
Expand Down

0 comments on commit 917ca58

Please sign in to comment.