Vue-resource: I can't use "get" with parameters

Created on 8 Aug 2016  ·  10Comments  ·  Source: pagekit/vue-resource

This is my code

var data = {page: page};
                this.$http.get('api/products', data ).then(
                        function (response) {
                            //look into the routes file and format your response
                            this.$set('items', response.data.data.data);
                            this.$set('pagination', response.data.pagination);

                        }, function (error) {
                            // handle error
                        });

I got this from this example https://github.com/JellyBool/laravel-vue-pagination/blob/master/resources/views/welcome.blade.php#L94

But I cant use GET, it doesn't send the parameters. Only clean url (/api/products)
What am I doing wrong?

Most helpful comment

with 0.9 you need to use params attribute:

                this.$http.get('api/products', {params:  {page: page}} ).then(
                        function (response) {
                            //look into the routes file and format your response
                            this.$set('items', response.data.data.data);
                            this.$set('pagination', response.data.pagination);

                        }, function (error) {
                            // handle error
                        });

All 10 comments

with 0.9 you need to use params attribute:

                this.$http.get('api/products', {params:  {page: page}} ).then(
                        function (response) {
                            //look into the routes file and format your response
                            this.$set('items', response.data.data.data);
                            this.$set('pagination', response.data.pagination);

                        }, function (error) {
                            // handle error
                        });

You saved my day :)

Oh my God !

No clear document about this?

thanks man!!!

In case of GET this solution is working but not in case of POST, any suggestions?

Perfect was looking for this answer for a month now.

My day is saved!! Thank you so much!

@webreinvent for POST you just need {someKey: 'someValue'}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

briward picture briward  ·  4Comments

V-Tom picture V-Tom  ·  3Comments

ionutvelicu picture ionutvelicu  ·  5Comments

gbhlwm picture gbhlwm  ·  5Comments

Creabine picture Creabine  ·  3Comments