-2
Good afternoon, everyone,
I’m new in the area and I’m having difficulty developing a code that runs Function2 only after the return of Function1.
How can I adjust the code for Function2 to run only after the return of Function1?
functionExample = () => {
var distance = require('google-distance-matrix')
var origins = [location1]
var destinations = [location2]
// Função1:
distance.matrix(origins, destinations, (err, distances) => {
if (err) {
console.error(err, 'status', distances1.status)
console.log("Erro")}
if (distances.status === "OK") {
ArrayExample.push((distances.rows[0].elements[0].distance.value / 1000))}
})
// Função2:
functionExample2()
}