ajax call from javascript to web api request token

0 favourites
  • 1 posts
From the Asset Store
Medeival & Viking War Horns Sounds / 22 Unique Calls / 2:40 minutes of audio
  • Hello there

    I have made a asp.net web api and enabled cors.

    I am trying to call from REX jsshell my web api like in postman.

    Do anyone have an example of this USING JSSHELL OR SOMETHING ELSE. I am running out of ideas.

    Scripts:

    function RequestLogin(usr,pwd)

    {

    var bearer ="";

    var user ={

    grant_type:'password',

    username:usr,

    password:pwd

    };

    $.ajax({

    type: "POST",

    url: "https://DUMMY.COM/token",

    data:user,

    contentType: "application/x-www-form-urlencoded",

    dataType: "json",

    success: function (data) {

    bearer = JSON.parse(JSON.stringify(data));

    bearer = bearer.access_token;

    },

    failure: function (response) {

    console.log(response);

    },

    error: function (response) {

    console.log(response);

    }

    });

    return bearer;

    }

    kind regards

    Steen

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)