LoginSignup
0
0

More than 3 years have passed since last update.

【JavaScript, Node.js】axiosでGETする際、レスポンスデータが文字化けしていた場合の対応方法

Posted at

*個人的なメモです。

axiosでGETする際、レスポンスデータが文字化けしていた

Line-MessageApiにて、コンテンツを取得するAPIを叩いた時のお話。

get-content
GET https://api-data.line.me/v2/bot/message/{messageId}/content

レスポンスが文字化けしていた。ほかのAPIたたいた時は問題なかったのに......

そんな時は、axiosの responseType responseEncoding を付け加える。

axios.create
axios.create({
    responseType: 'arraybuffer',
    responseEncoding: 'binary',
})

これで文字化けが解消した。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0