I am newer to Node/Express and am using this as my backend to integrate with Azure Blob Storage. Specifically, I am able to create an Azure blob container on click client side in Angular by using the following:
Angular Controller (tied to an ng-click event):
$scope.createContainer = function () {
// Create Blob Container
$http.get('/createcontainer').success(function (data) {
console.log(data);
});
};
Node/Express Backend that creates the Blob Container:
app.get('/createcontainer', function (res, req) {
function generateUnique() {
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
var containerNamePart1 = guid();
var now = new Date();
var containerNamePart2 = dateFormat(now, "yyyymmddhhMMss");
var containerName = containerNamePart1 + "-" + containerNamePart2;
blobSvc.createContainerIfNotExists(containerName, function (error, result, response) {
if (!error) {
console.log(result);
if (result === false) {
generateUnique();
}
// Container exists and allows
// anonymous read access to blob
// content and metadata within this container
}
});
}
generateUnique();
});
What I need to do is pass back the name of the blob container created in my backend (Node/Express) to my Angular front end (controller) so it can be used as a variable for some other operations. How do I pass variables or data from Node/Express backed to the front end for use/consumption?