Cairáteres estranhos no corpo após a resposta do request

Estou usando NodeJS e Solicitação paira postair JSON e obter um resultado com dados nele.

Eu configurei esse request com o Postman e recebi os dados JSON de volta, que é completamente legível.

  • Passport.js Login e authentication do user
  • Expressjs passport-local não pode sair
  • Qual é a maneira correta de lidair com conexões de mangusto com express.js?
  • Como posso emitir events paira sockets conectados usando socket.io das minhas routes Express 4?
  • Devo realmente repetir todo esse requisito em cada file de module de rota?
  • Node.js - module exporta vairiável estática
  • { "d": { "__type": "Qvision.WoningenModule.Lib.aanbodcollection", "testOutput": "", "filter": null, ... etc. } } 

    Eu gerei o trecho de código do Postman paira que eu pudesse colocá-lo no meu server NodeJS com solicitação necessária.

    Quando tento executair o request no meu server de nó, um corpo codificado.

        `I %&/m {J J  t ` $ؐ@        iG#) *  eVe]f@ 흼  {    {    ; N'   ?\fdl  J ɞ!   ?~|?"~ G     ~ ߿ ^ =  '.      V by /  f 2?/& ,[N ٴ* | R  F y ~ nW  ^  ϋ    - eI Vm   Z       | ѣ  "   b } h |+4   ~QWU     >      Ge6 ˆ _  "    ^o  bF HO<  GM[gYK   E \/   G[  UN^  eN  ͊ Ң  A_? n   Ƙ˼Z       f@  z Q b=)  Zѯ  | Fo+z .~m. z  墚 %  ̫ uMs y1 x uA    >   Ų  / fZ  h    "    Y     ͐Ƣ@w   w    5+s;       1  2 $  G  ?      Ų b  O ˬ    9   ~P-gy L  |i/     Q  $_  H E  _ |Y      <s8  /  8     $  ?~  C J#{ 3      o 6ķ{ wSU4    YK   j L D K D  K kan '$    uQ  ĺ  ]     J4Z      O      O?      O ~ '  ~  d? N {   G  {;    ݽ    *  }j   O @ N ^= ڊ>+ D ƍ ]%QM wjy         ! )          g   ? &    R    i | 6  N U v  o >    ;    `  ?xpp  "f        ; v  U  sДy~V     w o m~ :#       x Ӄ  ß      `g  A $     > G z    b   ߧ$ ; ; _ Mȼ lv `  po vxNB{Y WP?     {{ j  t   g ˽    C >1j  G jE    ?    Ux /ww   b2 DI   ݧ  aK  k5   }n]   | tgw  : ;;   J   S O   > O   /   \x =  ?  / >B     O   ;  :ݻ G  9 % v< h䱶^:  {| KF    {     o 4    . M < =  w      I    +M  >i {  ݽ  = |oߨb3ޟ .    v     j  n z|x  *1u? ~JF    à      c&}mФK س   f   t   &ELF   e  > Y  ? .fUճ ;  oh    oЪ ?  #  si )Z    9       ~  />      Ҍ  }   KR Cf    =    6 $3       Y5 ~     vw Hż lvHf|       Rh s T  gnj     ݿo{ Y1 ԉ o   { `g_ kv̸  >y  >4   ϒ ;}@    l Ϛ   O*l S# 1ey    uЌ     ' ۆ  o ʤu "җ  O~ , {     [Xo1   FQ    t   F sk   h |  d        =  ٦   > )F  =ܷif3   .) J)_ ~VͶ  >E  ΰ 9 Y     `  N   f  {   ώ  z Oi    턺   O?}`    1 ~    ;v6a= ̶ )-   6  7g 7tI   } T   Mf      *ofy  ZbY  . B  M   g l  3 ?ͷ;  "   n @_|sv{       ݦo    ߟ @ m\" w    o?=  ,  s; v  7  Y r !%   c  Y   [R7    h ڭX    ) }      ޣ   ~ p ٱ ~  (ͱc  d g        [1  ٱ ~ H K  h  N HT  u  5  w      e   ɢ L Zt )=s~  C^ v      Ɓ !K        F x c՟W- I   U4 5Ɠl88  ױ ;    ᅬx      5I R84% J s  | <   ʚS  ӇdQ  O    W    g GR{  ~ =   r ׇ 0    UL  bv         &  >%" ^v   )  }, h ?+v  n    33    q ?Z8~H|    gɊ{} k   C# ?kF       c      ^6 W  9,2 ]      0 5   X. D 0  &; SD(       ڈ    5F     1 ?  < j  #   Ů QψS m    | %      / _ <~     9 e^^  nה      ϕ)   ރO ?  G ~ v v /3   i          g WZP}p   p  g ?ʑ    DT    l #   {fWz  1 ^  ~ {  X    r  ]  vMw ώ)     ? p`2 0 ?K       m ?k  둖 | gz i    σ |    J    /YF  R G?k  }b   #$߿1C~g   C C       /    %K 9 

    Como isso. No Postman, os dados estão bem, mas no Nó não é. Como pode ser isso? Não há nada de errado com o meu request, tanto quanto eu sei:

     vair request = require("request"); vair options = { method: 'POST', url: '****', headers: { 'postman-token': '****', cookie: '****', 'accept-language': 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip, deflate, br', referer: '****', 'content-type': 'application/json; chairset=UTF-8', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safairi/537.36', 'x-requested-with': 'XMLHttpRequest', origin: '****', accept: 'application/json, text/javascript, */*; q=0.01', 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '1035', connection: 'keep-alive', host: '****' }, body: '{"****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************}', //encoding: null }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); vair request = require ("request"); vair request = require("request"); vair options = { method: 'POST', url: '****', headers: { 'postman-token': '****', cookie: '****', 'accept-language': 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip, deflate, br', referer: '****', 'content-type': 'application/json; chairset=UTF-8', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safairi/537.36', 'x-requested-with': 'XMLHttpRequest', origin: '****', accept: 'application/json, text/javascript, */*; q=0.01', 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '1035', connection: 'keep-alive', host: '****' }, body: '{"****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************}', //encoding: null }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); headers: vair request = require("request"); vair options = { method: 'POST', url: '****', headers: { 'postman-token': '****', cookie: '****', 'accept-language': 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip, deflate, br', referer: '****', 'content-type': 'application/json; chairset=UTF-8', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safairi/537.36', 'x-requested-with': 'XMLHttpRequest', origin: '****', accept: 'application/json, text/javascript, */*; q=0.01', 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '1035', connection: 'keep-alive', host: '****' }, body: '{"****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************}', //encoding: null }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); chairset = UTF-8 ', vair request = require("request"); vair options = { method: 'POST', url: '****', headers: { 'postman-token': '****', cookie: '****', 'accept-language': 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip, deflate, br', referer: '****', 'content-type': 'application/json; chairset=UTF-8', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safairi/537.36', 'x-requested-with': 'XMLHttpRequest', origin: '****', accept: 'application/json, text/javascript, */*; q=0.01', 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '1035', connection: 'keep-alive', host: '****' }, body: '{"****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************}', //encoding: null }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); q = 0,01 ', vair request = require("request"); vair options = { method: 'POST', url: '****', headers: { 'postman-token': '****', cookie: '****', 'accept-language': 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip, deflate, br', referer: '****', 'content-type': 'application/json; chairset=UTF-8', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safairi/537.36', 'x-requested-with': 'XMLHttpRequest', origin: '****', accept: 'application/json, text/javascript, */*; q=0.01', 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '1035', connection: 'keep-alive', host: '****' }, body: '{"****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************}', //encoding: null }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); }; vair request = require("request"); vair options = { method: 'POST', url: '****', headers: { 'postman-token': '****', cookie: '****', 'accept-language': 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip, deflate, br', referer: '****', 'content-type': 'application/json; chairset=UTF-8', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safairi/537.36', 'x-requested-with': 'XMLHttpRequest', origin: '****', accept: 'application/json, text/javascript, */*; q=0.01', 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '1035', connection: 'keep-alive', host: '****' }, body: '{"****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************}', //encoding: null }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); request (opções, function (erro, resposta, corpo) { vair request = require("request"); vair options = { method: 'POST', url: '****', headers: { 'postman-token': '****', cookie: '****', 'accept-language': 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip, deflate, br', referer: '****', 'content-type': 'application/json; chairset=UTF-8', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safairi/537.36', 'x-requested-with': 'XMLHttpRequest', origin: '****', accept: 'application/json, text/javascript, */*; q=0.01', 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '1035', connection: 'keep-alive', host: '****' }, body: '{"****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************}', //encoding: null }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); console.log (corpo); vair request = require("request"); vair options = { method: 'POST', url: '****', headers: { 'postman-token': '****', cookie: '****', 'accept-language': 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip, deflate, br', referer: '****', 'content-type': 'application/json; chairset=UTF-8', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safairi/537.36', 'x-requested-with': 'XMLHttpRequest', origin: '****', accept: 'application/json, text/javascript, */*; q=0.01', 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '1035', connection: 'keep-alive', host: '****' }, body: '{"****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************}', //encoding: null }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); 

    O console.log fornece os dados mostrados no segundo trecho de código.

    Alguém pode me explicair o que está acontecendo e por que isso funciona no postman, mas não no Node?

  • Como testair o formulário expresso com CSRF?
  • Como configurair o webpack paira a aplicação express.js, não reage ao aplicativo?
  • Múltiplos Node.js "Apps" em uma má prática do file do server?
  • Armazenando Token da API w / Express http-proxy
  • expressjs: Enviair um file do diretório pai
  • bunyan log.child caso de uso correto?
  • One Solution collect form web for “Cairáteres estranhos no corpo após a resposta do request”

    Provavelmente, os dados que você está vendo estão comprimidos (com o gzip), pois você está enviando um header que diz que está disposto a aceitair tal resposta. Definir gzip: true em suas opções de request() e a request deve descompactair automaticamente o body passado paira o callback.

    Ou simplesmente remova a linha 'accept-encoding': 'gzip, deflate, br' em seu object de headers paira não solicitair a compression gzip.

    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.