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":"https://pixabay.com/photos/shoes-legs-car-car-window-woman-434918/","type":"photo","tags":"shoes, legs, car","previewURL":"https://cdn.pixabay.com/photo/2014/09/03/20/15/shoes-434918_150.jpg","previewWidth":150,"previewHeight":100,"webformatURL":"https://pixabay.com/get/g033b9a74fbf574cea17d172e0e94737aeff33de5afb14e8bc5697c24c0ad55f1e555be1534f28165e649e6659502f362_640.jpg","webformatWidth":640,"webformatHeight":429,"largeImageURL":"https://pixabay.com/get/ge519a8e17a3f3e399546066731852501aa10abb51eedf1ca37db4d77ecb54d9e034f007a97ddd30db733ffd1148779ae267f7aac6c7e36c8d914f1cb8727f5ba_1280.jpg","imageWidth":2165,"imageHeight":1453,"imageSize":587598,"views":1027652,"downloads":525169,"collections":2088,"likes":1646,"comments":325,"user_id":2323,"user":"Greyerbaby","userImageURL":"https://cdn.pixabay.com/user/2014/11/14/05-39-07-629_250x250.jpg"},

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.