Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda