Getting list of images from database
Hi,
While fetching a list of informations which includes pictures from a database table, I fetch the list of the names of that pictures and trying to show each of the pictures that I got its names with the code below :
var data2;
var serverUrl = 'https://api.appery.io/rest/1/db/files/' + value;
$.ajax({
type: "GET",
headers: {'X-Appery-Database-ID':deneme_settings['database_id'],'X-Appery-Session-Token':localStorage.getItem('sessionTokenId')},
url: serverUrl,
processData: false,
success: function(data) {
console.log("Successfully loaded");
data2= "data:image/png;base64," + data;
flag = false;
},
error: function(xhr) {
console.log("Load error: " + xhr.status + " " + xhr.responseText);
}
});
return data2;
The code returns before the picture is uploaded, so the place that the picture should be there stays blank. How can I make wait the code to provide it is uploaded before returning?
Best regards,
Edebali