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

271
Vistas
Convert array of images to base64 using readAsStringAsync in React Native

I have the following code:

export const blSaveRecord = async (data) => {

  const params = new URLSearchParams()

  params.append('DocumentNumber', data.DocNumber)

  data.People.map((item, index) => {
     params.append(`Person[${index}].PersonDoc`, item.PersonDoc)
     params.append(
        `Person[${index}].Document[0].Base64File`,
        `data:image/jpg;base64,${FileSystem.readAsStringAsync(item.image, {
          encoding: FileSystem.EncodingType.Base64,
        })}`
     )
    })

    //THIS IS THE ISSUE:
    console.log(params)

    return axios
      .post(url_SaveRecord, params)
      .then(function (response) {
        return {
          status: true,
          message: '',
        }
      })
      .catch(function (error) {
        return {
          status: false,
          message: error.message,
        }
      })
  })

The issue is that the method readAsStringAsync is Async, but I cant get to work with await. I tried to call another async function to make this method and wait for it but its not possible.

The question is... how can I wait to an async function to complete inside a map? I dont want to go to next iteration until the async is complete.

Thanks.

about 4 years ago · Juan Pablo Isaza
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