user1765862
user1765862

Reputation: 14145

simple $http.get request with params

I'm trying to make following http request using angularjs $http service

$http.get('http://myserver:8080/login?', {
            params:  {username: "John", password: "Doe" },
            headers: {'Authorization': 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='}
        }).then(function(response) {
            alert('success');
            alert(response);
            }, function(x) {
              alert('err');
            });
        };

my server is up and runing and I'm getting following firebug console error enter image description here

So what I'm doing wrong here in sending http request?

Upvotes: 0

Views: 57

Answers (1)

Drag13
Drag13

Reputation: 5988

Here is an example for send GET request using $http.get with params

$http.get('api/anyApi/get', { params: {name:name}})

As you see, you do not need absolute path and ? param to use.

Also, as jfadich mentioned - do not use GET for such requests.

Upvotes: 1

Related Questions