Daily iOS
Networking토스

Sending JSON POST with URLRequest

For a take-home assignment you wrote this code that POSTs JSON with URLRequest. Select all the statements that correctly describe problems with it.

func submit(_ body: Order) async throws -> Receipt {
    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.httpBody = try JSONEncoder().encode(body)
    let (data, _) = try await URLSession.shared.data(for: request)
    return try JSONDecoder().decode(Receipt.self, from: data)
}

Pick all that apply

Submit