Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

how to set charset when set emulateJSON? #326

Closed
u1zz opened this issue Jul 9, 2016 · 2 comments
Closed

how to set charset when set emulateJSON? #326

u1zz opened this issue Jul 9, 2016 · 2 comments

Comments

@u1zz
Copy link

u1zz commented Jul 9, 2016

I need change the charset to utf-8.

Vue.http.options.emulateJSON = true
// set charset
Vue.http.options.headers = {
  'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
// or 
Vue.http.options.beforeSend = function(request) {
    request.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
};

but on request has data, the 'Content-Type' aways equal application/x-www-form-urlencoded;
1

@ducho
Copy link

ducho commented Jan 27, 2017

Hi.
I've got same problem. I'm using Vuejs + vue-resource with Symfony 3.
Did you already solved this problem ?
Dusan.

@u1zz
Copy link
Author

u1zz commented Feb 3, 2017

Vue.http.options.emulateHTTP = true
Vue.http.options.headers = {
  'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
Vue.http.interceptors.push((request, next) => {
  let body = request.body
  if (body) {
    let array = []
    for (var key in body) {
      array.push(key + '=' + body[key])
    }
    request.body = array.join('&')
    // ...
  }
})

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

No branches or pull requests

3 participants