kean / Get

Web API client built using async/await
MIT License
937 stars 74 forks source link

Conforming to `Codable` #74

Closed wmorgue closed 1 year ago

wmorgue commented 1 year ago

Hi Alex 🤝 Is it possible to conform a struct Response to Codable?

My data model conforms to Codable and has a Response<String> property. I implemented a func encode(to encoder: Encoder) throws { and init(from decoder: Decoder) throws { but I'm getting an error:

let response: URLResponse does not conform to Codable.

I understand what this error means.

kean commented 1 year ago

Hi, Response is not designed to be Codable: it has URLSessionTask, raw response Data, and other URLSession-related types that are not Codable.

wmorgue commented 1 year ago

I realized what needed to be done 👍🏻