Generation

generate functionSun, 16 Jul 2023

función donde se haga la conexión a la url https://jsonkeeper.com/b/MX0A. Esta URL contiene el JSON con el listado de los productos que se debe mostrar en la aplicación.

func post(url: String, body: Data? = nil, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) { let request = NSMutableURLRequest(url: NSURL(string: url)! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: completionHandler) dataTask.resume() }

Questions about programming?Chat with your personal AI assistant