Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
Alamofire upload JSON response not compiling

I'm doing an Alamofire upload to the server and want to decode some JSON that's sent back in response.

AF.upload(multipartFormData: { multiPart in
    //do upload stuff to the server here
        }, to: server)
        .uploadProgress(queue: .main, closure: { progress in
            //Current upload progress of file
            print("Upload Progress: \(progress.fractionCompleted)")
        })
        .responseJSON(completionHandler: { data in
            guard let JSON = data.result.value else { return }
            print("JSON IS \(JSON)")
            //decode the JSON here...
        })

On the line where I'm guarding that data.result.value has a value (the JSON response sent from the server), I'm getting a 'Type of expression is ambiguous without more context'.

The code to send the JSON object from the server looks like this on the Node.js side:

app.post('/createCommunity', upload.single('cameraPhoto'), async function (request, response) {
    // do operations to get required variables
    var returnObject = {
      community_id: id,
      title: title,
      members: members,
      image: imageURL
    }
    response.send(returnObject)
}

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Since you already have a codable/decodable Community struct, try this approach:

    AF.upload(multipartFormData: { multipartFormData in  
    //do upload stuff to the server here 
    }, to: server)  
   .responseDecodable(of: Community.self) { response in 
        debugPrint(response)     
    }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda