سؤال

I have a custom api on my Mobile Service that looks like some variables are getting overridden when 2 users call it at the same time.

I'm calling the script by the "POST" method. Below I show the initial part of the script. Can some one give me more information on the scope of the variables defined at the top ? Could it be possible that 2 users be using the same variables ?

var tableArray = null;
var requestObject = null;
var responseObject = null;
var accountFunctions = null;
var userID = 0;
var serverSyncTimeStamp = 0;
var clientSyncTimeStamp = 0;
var random = 0;
var start = null;
var time  = null;

exports.post = function(request, response) {
    if (request.query.userID === null) {
        response.send(statusCodes.BAD_REQUEST,'did not supply a userID');
        return;
    }


    start = new Date().getTime();
    cleanUp();
    accountFunctions = require('../shared/accountFunctions.js');
    random = Math.random();
    userID = Number(request.query.userID);
    ETC ETC ETC ..........
هل كانت مفيدة؟

المحلول

For Custom API's, the global scope is shared between all executions. (Unlike with table scripts, where each script execution has its own global scope)

So yes, each time a POST to your API happens, they will modify the same set of variables.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top