Axios-module: Response returns weird characters

Created on 25 Mar 2018  ·  1Comment  ·  Source: nuxt-community/axios-module

I'm making a request to an external API. Everything works fine except response.data is returning something like this:

!�♥  ♠��        ▲,Zp→↔�<☼D#�.
�8�(N ☼hHs'>☼1�;�_↑►↕�♂↔^a�/�♀����D0�}♫ԥ>V►�↨�09�����4]♣ghn�q��◄�v�aޏ[�↕��G↑�i>my■�♂� sX�<♂�1ܛ~�O����V�8]↨-IT�_↑
  • nuxt 1.4.0
  • @nuxtjs/axios ^5.1.1

nuxt.config.js

module.exports = {
    modules: [
        '@nuxtjs/axios',
    ],

    axios: {
        baseURL: 'https://www.example.com/api',
        progress: true,
        credentials: true
    },
};

This question is available on Nuxt.js community (#c109)

Most helpful comment

Turns out it has to do with the default value of the accept-encoding header. The server I'm making calls to is using the br value in the header.

$axios.setHeader('accept-encoding', '*'); or gzip or null fixes it.

EDIT: null works better than *. You don't get Refused to set unsafe header "accept-encoding" in Chrome.

>All comments

Turns out it has to do with the default value of the accept-encoding header. The server I'm making calls to is using the br value in the header.

$axios.setHeader('accept-encoding', '*'); or gzip or null fixes it.

EDIT: null works better than *. You don't get Refused to set unsafe header "accept-encoding" in Chrome.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mclighter picture mclighter  ·  3Comments

tebaly picture tebaly  ·  3Comments

seanwash picture seanwash  ·  6Comments

kaboume picture kaboume  ·  4Comments

ealves-pt picture ealves-pt  ·  3Comments