javascript - ReferenceError: item is not defined in Azure insert script -


i using following code in insert perform push notifications. todoitem table contains imageurl , channel table has channl uris. reference code here-http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-store-dotnet-get-started-push-vs2012/

the following code insert script in todoitem table

var azure = require('azure');  var qs = require('querystring');  var appsettings = require('mobileservice-config').appsettings;    function insert(item, user, request) {      // storage account settings app settings.      var accountname = appsettings.storage_account_name;      var accountkey = appsettings.storage_account_access_key;      var host = accountname + '.blob.core.windows.net';        if ((typeof item.containername !== "undefined") && (          item.containername !== null)) {          // set blob store container name on item, must lowercase.          item.containername = item.containername.tolowercase();            // if not exist, create container          // public read access blobs.                 var blobservice = azure.createblobservice(accountname, accountkey, host);          blobservice.createcontainerifnotexists(item.containername, {              publicaccesslevel: 'blob'          }, function(error) {                  if (!error) {                        // provide write access container next 5 mins.                             var sharedaccesspolicy = {                          accesspolicy: {                              permissions: azure.constants.blobconstants.sharedaccesspermissions.write,                              expiry: new date(new date().gettime() + 5 * 60 * 1000)                          }                      };                        // generate upload url sas new image.                      var sasqueryurl =                          blobservice.generatesharedaccesssignature(item.containername,                              item.resourcename, sharedaccesspolicy);                        // set query string.                      item.sasquerystring = qs.stringify(sasqueryurl.querystring);                        // set full path on new new item,                      // used data binding on client.                      item.imageuri = sasqueryurl.baseurl + sasqueryurl.path;                    } else {                      console.error(error);                  }                  request.execute({         success: function() {             request.respond();             sendnotifications();         }     });              });      } else {          request.execute({         success: function() {             request.respond();             sendnotifications();         }     });     } } function sendnotifications() {         var registrationstable = tables.gettable('channel');         registrationstable.read({             success: function(registrations) {                 registrations.foreach(function(registration) {                     push.wns.sendtoasttext04(registration.handle, {                         text1: item.text                     }, {                         success: function(pushresponse) {                             console.log("sent push:", pushresponse);                         }                     });                 });             }         });     } 

the error error in callback table 'channel'. referenceerror: item not defined @ :122:32 [external code] @ object.registrationstable.read.success (:120:31) [external code]

can please let me know how resolve this?

the problem in block of code: success: function(registrations) { }.

i remove call push.wns , log console try debug. check 'item' exists. if you're using online node editor show if have unmatched brackets.

i'm assuming have configured wns use in azure portal?


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -