Home > Software design >  Response encoding filled with diamond characters with question marks. Express, Axis, and Node
Response encoding filled with diamond characters with question marks. Express, Axis, and Node

Time:11-24

I'm currently using express, node, and prisma to create a server but whenever I request a GET request to another API using axios, the response data contains diamond characters with questions marks. I've specified the charset and responseEncoding to utf-8 but that didn't solve anything. Any suggestions?

import axios from "axios";

export function xola() {
  const options = {
    method: "GET",
    url: "https://sandbox.xola.com/api/categories",
    headers: {
      accept: "application/json",
      "X-API-VERSION": "2017-06-10",
    },
    charset: "utf8",
    responseEncoding: "utf8",
  };

  axios
    .request(options)
    .then(function (response) {
      console.log(response.data);
    })
    .catch(function (error) {
      console.error(error);
    });
}

diamonds with question marks

CodePudding user response:

I would suggest to check version of your axios library.

Looks like the latest version 1.2.0 of axios has changes in the response decompression logic and it doesn't work if server does not set the response content-length header. If that's a case - just temporary downgrade to the last stable version 1.2.3 i.e.:

npm i [email protected]
  • Related