user3100209
user3100209

Reputation: 367

Spring RESTful backend and Angularjs front end : How to add parameters from the client side?

I have a spring restful backend, one of the mapping is this:

    @RequestMapping("/getPeopleList")
    public List<Person> getPeeps(@RequestParam(value="ssid", required=true) Integer ssid){
    return Backend.getPeople(ssid);
   }

How do i make a request to this api? I am doing this with my angularjs

   $http.get(url+'/getPeopleList').success(function(peeps) {

        console.log(peeps);
    });

but this doesnt work...... I also tried this

     $http.get(url+'/getPeopleList/234').success(function(peeps) {

        console.log(peeps);
    });

The id 234 is a random id but that doesn;'t work either. I get 404 or 400 bad request everytime .

Upvotes: 0

Views: 106

Answers (1)

Nikolay Rusev
Nikolay Rusev

Reputation: 4230

you are asking for @RequestParam but you are passing @PathVariable. Please see their doc. Just change to :

 $http.get(url+'/getPeopleList?ssid=234').success(function(peeps) {
        console.log(peeps);
    });

Upvotes: 1

Related Questions