Search code examples
firefox-addonfirefox-addon-sdk

How to get the response body in utf8 format in firefox add-on using request


I user request in firefox add-on and I got headers details but I don't know how to get response body can any one help me out. I got full text using response.text but I need it in utf8 format for example(in node we use encoding(utf8)). I tried json.parse, but it returns null, though I get response.text
https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/request


Solution

  • You can see all the response object properties on this part of the page. I use response.json as it's already a JavaScript object (effectively the same as JSON.parse(response.text);)