类似的邮件请求邮递员的回复,而不是angulat $ http.post

时间:2017-09-29 11:28:43

标签: angularjs http post http-headers

有用于获取用户令牌的帖子请求。我已经使用了角度$ http.post方法在我的浏览器网络窗口中它没有给我回复但是当我在邮递员中尝试这个它给我回复这里是屏幕截图附加 请帮助
first image

reponse image

postman image

this.login = function (loginData) {

        var data = "grant_type=password&username=" + loginData.userName + "&password=" + loginData.password;

        //if (loginData.rememberMe) {
        data = data + "&client_id=" + constants.AUTHSETTINGS.CLIENT_ID;
        //}
        debugger;
        console.log(data)

        var deferred = $q.defer();
        $http.post(api_url + '/token', data, { 
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
         })
        .then
        (function (response) {
            if (loginData.rememberMe) {
                localStorageService.set('authorizationData', { token: response.data.access_token, userName: loginData.userName, refreshToken: response.data.refresh_token, useRefreshTokens: true });
            }
            else {
                localStorageService.set('authorizationData', { token: response.data.access_token, userName: loginData.userName, refreshToken: "", useRefreshTokens: false });
            }
            console.log('---auth servcie')
            console.log(response)
            authentication.isAuth = true;
            authentication.userName = loginData.userName;
            authentication.useRefreshTokens = loginData.rememberMe;

            deferred.resolve(response);
        }
        ,function (err, status) {
                console.log('auth error -- here ')
                console.log(err)
                console.log(status)
                deferred.reject(err);
                //deferred.resolve(err);
            });


        return deferred.promise;
    };

原始数据     var data =" grant_type = password& username=asad@gmail.com& password = 1234& client_id = angularjs

0 个答案:

没有答案