Hello,
Can anybody help me with the following error?
Fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.typeMismatch(Swift.Array, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array but found a dictionary instead.", underlyingError: nil)): file JSonParcingTest.playground, line 22
this is the line of code that I am testing in Xcode swiftUI Playgroung
import UIKit
struct ProductRequest: Codable {
let dateRequested: String
let comments: String
}
let url = URL(string: "https://api.globaldooh.com/products/getproducts/f69c6f4d-0aff-45c5-8ccd-660b022f3557/90/gucci/11/2")!
URLSession.shared.dataTask(with: url) { data, _ , _ in
if let data = data {
let productrequest = try ! JSONDecoder().decode([ProductRequest]. self , from: data)
print(productrequest)
}
}.resume()