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

244
Vistas
async function not being called in callback of another function

I have a simple class that loads in a google map, does some ajax and then on that response will eventually place some markers on the map, the class looks like, this,

class Map extends BaseComponent {

    constructor(element) {
        super(element);
        this._element = element;
        this.init();
    }
    
    init() {
        this.initialiseLoader();
    }

initialiseLoader(position = {}) {
        const loader = new Loader({
            apiKey: 'xxxxxxxx',
            version: 'weekly',
            libraries: []
        });

        loader.load()
            .then((google) => {
                this.map = new google.maps.Map(document.querySelector('.lta-map'), {
                    zoom:12
                });
                this.map.setCenter({
                    lat: Manipulator.getDataAttribute(document.querySelector('.lta-map'), 'latitude'),
                    lng: Manipulator.getDataAttribute(document.querySelector('.lta-map'), 'longitude')
                });
                this.placeMarkers();
                return true;
            })
            .catch((error) => { alert(error) });
    }

    async placeMarkers() {
        const markers = await Request.get(`${this.endpoint}?/latititude=${Manipulator.getDataAttribute(document.querySelector('.lta-map'), 'latitude')}&longitude=${ Manipulator.getDataAttribute(document.querySelector('.lta-map'), 'longitude')}`)
        .catch(() => { 
            console.log('error');
        });

        console.log(markers);
    }
}

The maps loads fine but when it hits the this.placeMarkers() call I get an error message claiming that,

this.placeMarkers is not a function

Is it because it's an async function?

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

0

make initialiseLoader(position = {}) and placeMarkers() arrow functions like this

initialiseLoader = (position = {}) => { yout code here ...}

placeMarkers = () => { your code here .. }

and maybe move placeMarkers inside initialiseLoader

Thats all i can think of

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