pagekit / vue-resource

The HTTP client for Vue.js
MIT License
10.09k stars 1.6k forks source link

JSON query issue #405

Closed smallpath closed 8 years ago

smallpath commented 8 years ago

Maybe I'm missing something, but it seems that vue-resource translates the JSON query params to wrong url

store.fetchBlogByPage = (vue, page = 0, perPage = 10) => {

  return vue.$http.get(blogAPI,{
    params: {
      conditions: {
        type: 0
      },
    }
  })

Sample code is above.

The request uri is /post?conditions%5Btype%5D=0 which decoded to /post?conditions[type]=0. However, This query of request will be ignored by Koa2 bodyParser.

/post?conditions={"type":0} works fine using POSTMAN, but vue-resource translates it to /post?conditions[type]=0, too

I tried the $resource but still failed. It seems that any input url will be converted by vue-resource. How can I get the correct JSON query uri?

smallpath commented 8 years ago

Ok, it seems that URL template does not support JSON string, So I divide the JSON query into 2 Array querys. Now it works fine.