Can not return "result" in xhr.then (‘dojo/request/xhr’)

I have some problems when I return “result” in xhr.then() and I use dojo 1.10.4 Pls help me!

The below code which connects to API with xhr (‘dojo/request/xhr’) in dojo:

remandFlow: function(postData, flowId) {
        return xhr(this.REMAND_URL + flowId, {
            method: 'POST',
            data: postData,
            handleAs: 'json',
            headers: {'X-CSRFToken': cookie("csrftoken")}
            lang.hitch(this, function(result){
                return result;
            lang.hitch(this, function(error){
                return error;

The below code which gets result of above code:

editStepUser: function(stepComponent, routeComponent) {

                console.log(result) //I can not get it, It's undefined
                result.targeted_step_id = postData.route_step_id;
                result.targeted_step_id = postData.route_step_id;

So, in the second code, I can’t get result, result is “undefined”. Please help me, I’m a newbie dojo.


Source: ajax

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.