Next.js Discord

Discord Forum

Help with a function call

Unanswered
Tomistoma posted this in #help-forum
Open in Discord
Avatar
TomistomaOP
I'm sure there is a simple answer to this question, but I can not find it.
var imageLat is known in the callback function New ExifImage...
I would like to have it known outside the function.
What am I missing here?
Thanks in advance.


export function myfucn(id:any){

const ExifImage = require('exif').ExifImage;
let imageLat
new ExifImage({ image : 'public/images/IMG_1347.JPG' }, function (error:any, exifData:any) {
imageLat = exifData.gps.GPSLatitude;
console.log(imageLat)
return imageLat

});

}

console.log(imageLat) returns nothing.

3 Replies

Avatar
TomistomaOP
Is there too much or too little infor here? Or is the question to simply to warrent an answer? Just curious
Avatar
@Tomistoma can you log out exifData.gps.GPSLatitude also if you use a local variable.. does it work?
Avatar
what are you trying to do
myfucn() would already return the latitude why not directly call that and assign it to a variable?