Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query parameter is not sended in request #23

Closed
a47ae opened this issue Jun 26, 2016 · 7 comments
Closed

Query parameter is not sended in request #23

a47ae opened this issue Jun 26, 2016 · 7 comments

Comments

@a47ae
Copy link

a47ae commented Jun 26, 2016

Hey, when I tried out your component I recognized that the query parameter does not got send along with my request. I double checked in the ChromeDev tools but there is no GET parameter in the rquest send by vue-resource. But if I change the line
return this.$http.get(this.src, Object.assign(queryParam, this.data)) to
return this.$http.get(this.src, {params: Object.assign(queryParam, this.data)})
everything works as expected.

So maybe the params option needs to be statet explicitly?

@weklund
Copy link
Contributor

weklund commented Jun 27, 2016

Wait so you're saying what you're passing isn't working at all?

@alons182
Copy link

I have the same problem, the query parameter is not sended

@a47ae
Copy link
Author

a47ae commented Jun 27, 2016

So this is what the request looks like with the original code:
without_params - there is not query parameter.

And this is the modified code where I added params:
with_params
In the vue-resource documentation the syntax for get is get(url, [options]) so one have to pass a params option. Maybe they changed the syntax in the recent version?

@alons182
Copy link

Exactly, with your change works fine (return this.$http.get(this.src, {params: Object.assign(queryParam, this.data)}) )

@pespantelis
Copy link
Owner

Thanks @a47ae for the issue!

This is related with the recent changes on vue-resource as you said.
I'll change it when I'll publish the next major release with the [email protected].

Until then, we could use the [email protected] :)

@a47ae
Copy link
Author

a47ae commented Jun 30, 2016

Thanks for clearing that up!
Looking forward to the next release. :)

@b8ne
Copy link

b8ne commented Sep 30, 2016

Hi I am also experiencing this problem, I have just installed everything so assuming I have the latest versions.

package.json
{ "private": true, "scripts": { "prod": "gulp --production", "dev": "gulp watch" }, "devDependencies": { "bootstrap-sass": "^3.3.7", "gulp": "^3.9.1", "jquery": "^3.1.0", "laravel-elixir": "^6.0.0-9", "laravel-elixir-vue": "^0.1.4", "laravel-elixir-webpack-official": "^1.0.2", "lodash": "^4.14.0", "vue": "^1.0.26", "vue-resource": "^0.9.3" }, "dependencies": { "vue-typeahead": "^2.2.1" } }

Typehead.vue - script
`import VueTypeahead from 'vue-typeahead'

export default {
    extends: VueTypeahead, // [email protected]+
    // mixins: [VueTypeahead], // [email protected]

    data () {
        return {
            // The source url
            // (required)
            src: '../../../api/players',

            // Limit the number of items which is shown at the list
            // (optional)
            limit: 1,

            // The minimum character length needed before triggering
            // (optional)
            minChars: 1,

            queryParamName: 'name',
        }
    },

    methods: {
        // The callback function which is triggered when the user hits on an item
        // (required)
        onHit (item) {
            console.log(item)
        },

        // The callback function which is triggered when the response data are received
        // (optional)
        prepareResponseData (data) {
            // data = ...
            for (let item of data) {
                console.log(item.firstName);
            }
            return data
        }
    }
}`

EDIT* sorry got mixed up on repos, i applied this fix manually and all is working, just realised PR hasnt been merged yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants