Netlify function: API fetch result not a URL

Hello, I’m trying to fetch image url from an API using the netlify serveless function. The server output in the terminal is some kind of Buffer. Here’s how the response looks like:

Request from ::1: GET /.netlify/functions/getImages?keyword=
"\u0013 \n\u0000dS *J \u0018K+\u0000\u0004\bBArw \u001f9;\u0005 ` nlMk \u001b9ܼ>Hh \u000e\u001d >ȝ    |z [\u0014P  `a
\u0004\u0017   R  g RC X } L׎~\u0003\u0013      N , S  㼧]\u0000 t;  ?  1 Ι\r   \u001a  Ҟn  v߷    Ϳ  `  v   }}  }  
^|R\u00104^? >  j ܖ t~}    eҒN  Ӟl X.Oq /   iI SO\u0011  /   \u0007\u0017 o\u0004 \u001b \u0006y# P\\bG   \u0002 \u000f     1 [ Q` \u000b k\u001c ۙv\u0004X  h      ? 5  + Ѽ 3c    ڝ  1X \u0017U   \u0014Y \u0018 \f'6 \u001e=  \u0019 3\u
0015 \\@[ \b˝K\u0017   P\u0018>  vMK \u001cm  ?   c   \u0017 %}\u000e_ \u0011\u00143ْ\u0012w    cկ  (> A ۰l M @ G'   
  \u0004dֻ enf\u0010\u001a \r r+   kØ   i\u000ek ,\\ q 4| k   \u0004$ 6\\f   TcT\u001d ~  Q\u0012\u0016i \u0006 D \\ 
   - .U  >\u001d   v\u0004 \" $ , v! bK OO     v Z  t< = X ,\t/\u0013 = ,  = \u001f  vʔ : =  \u001e_ y   \u0005z ~ O  {  Ԉ\u001b \u0006 f[A B @\u0002_ \u0010 \\P \u0014 *)M  x9 \u001a+  }}{   \n8   6 \f\u0007\\\u0004 E\u0001\u0017 r \u0010v .O6 \u001b \ru#   X \u0000 #3  \u0006 \u0012 H-  d E ̈   @ \u001e \u0004J   ]I%C u ܑ+ 0j  g\r  \u0003y  ]g&d ?
\u0001  \n   K  Fͣ g P \" b=w\u001a4 \u0017  \r3 #{v  \u0005s)3z :K  \u0012\u001eڵ  \u0000\u00022j #b ̌1е\"V@d # \u00
03R \u000fDJ \u0000q \f  T f. \\    BL   I  \u0019 93x9 \u000e     xz:^   \u000b*ϹnP6 \rp  \u0002  R\u001a  %\u000b :__  OO   q||^o   ٿ /  v \u0006  & \u0006 \"\\. _.\u001a \u0004   \rdC (o@.r\"|OX |n  \u0018dsh\u0003Բ 1  l$8 L Ĥ:K)d  \u000b3w30 -\u001bk >FoU L   с%k0  ӹ   \u001e1D3 µ J \u0001   IW  \fةH aX\u0010   N}tt    {w ʥZ be  g f NÙy  ʊF   m 9\u0006itn\\J\u001d j\\yJ j`    V5\\C#S  \"\u0014 \fI D @ `( -  J \"&ZXH  -     S \u001c \u001b(  \u000fᆺb^% \u0019E 
  ~  '"

Response with status 200 in 667 ms.

The result I’m expecting:

{"id":434918,"pageURL":"","type":"photo","tags":"shoes, legs, car","previewURL":"","previewWidth":150,"previewHeight":100,"webformatURL":"","webformatWidth":640,"webformatHeight":429,"largeImageURL":"","imageWidth":2165,"imageHeight":1453,"imageSize":587598,"views":1027652,"downloads":525169,"collections":2088,"likes":1646,"comments":325,"user_id":2323,"user":"Greyerbaby","userImageURL":""},

If you’re using axios, it’s an axios issue:

Fixed in v1.2.1 (which has another issue by the way). Best to stay on v1.1.3 as of now.

1 Like

Thank you so much for the reference.

I got the solution from this comment: Error response data nodejs · Issue #5298 · axios/axios · GitHub

The server output is readable. :smile:

A side note, that’s a workaround and not a solution. The solution is to upgrade to the latest version (v1.2.1).

1 Like

Alright. Thanks for the update.