Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unexpected Response From API call using axios.get

I am trying to fetch some data using axios.get

The following endpoint takes in a currency and a value and then SHOULD return a single number, by converting the given value into Bitcoin.

`https://blockhain.info/tobtc?currency=${selected}&value=${amount}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I get a 200 response in Postman and in my app, however the following code returns the following:

<html>
  <head>
    <title>Loading...</title>
  </head>
  <body>
    <script type='text/javascript'>window.location.replace('https://blockhain.info/tobtc?ch=1&currency=ARD&js=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJKb2tlbiIsImV4cCI6MTY3NjI5MDM2MiwiaWF0IjoxNjc2MjgzMTYyLCJpc3MiOiJKb2tlbiIsImpzIjoxLCJqdGkiOiIydDFsbDlzb3NmYXEzaGRva28zZ2xoMG8iLCJuYmYiOjE2NzYyODMxNjIsInRzIjoxNjc2MjgzMTYyMTgzMDA4fQ.caJ-5pxUVIzmLQ1nSsKaamzwxj-rJkNHeVxlBXuLun8&sid=f1cb455e-ab81-11ed-9cae-f009f3843e4f&value=123');</script>
  </body>
</html>
LOG  {"config": {"adapter": ["xhr", "http"], "data": undefined, "env": {"Blob": [Function Blob], "FormData": [Function FormData]}, "headers": [Object], "maxBodyLength":
-1, "maxContentLength": -1, "method": "get", "timeout": 0, "transformRequest": [[Function transformRequest]], "transformResponse": [[Function transformResponse]], "transitional": {"clarifyTimeoutError": false, "forcedJSONParsing": true, "silentJSONParsing": true}, "url": "https://blockhain.info/tobtc?currency=ARD&value=123", "validateStatus": [Function validateStatus], "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN"}, "data": "
<html>
  <head>
    <title>Loading...</title>
  </head>
  <body>
    <script type='text/javascript'>window.location.replace('https://blockhain.info/tobtc?ch=1&currency=ARD&js=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJKb2tlbiIsImV4cCI6MTY3NjI5MDM2MiwiaWF0IjoxNjc2MjgzMTYyLCJpc3MiOiJKb2tlbiIsImpzIjoxLCJqdGkiOiIydDFsbDlzb3NmYXEzaGRva28zZ2xoMG8iLCJuYmYiOjE2NzYyODMxNjIsInRzIjoxNjc2MjgzMTYyMTgzMDA4fQ.caJ-5pxUVIzmLQ1nSsKaamzwxj-rJkNHeVxlBXuLun8&sid=f1cb455e-ab81-11ed-9cae-f009f3843e4f&value=123');</script>
  </body>
</html>
", "headers": {"accept-ch": "Sec-CH-UA, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Mobile", "cache-control": "max-age=0, private, must-revalidate", "content-length": "504", "content-type": "text/html; charset=utf-8", "date": "Mon, 13 Feb 2023 10:12:42 GMT", "server": "Cowboy"}, "request": {"DONE": 4, "HEADERS_RECEIVED": 2, "LOADING": 3, "OPENED": 1, "UNSENT": 0, "_aborted": false, "_cachedResponse": undefined, "_hasError": false, "_headers": {"accept": "application/json, text/plain, */*"}, "_incrementalEvents": false, "_lowerCaseResponseHeaders": {"accept-ch": "Sec-CH-UA, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Mobile", "cache-control": "max-age=0, private, must-revalidate", "content-length": "504", "content-type": "text/html; charset=utf-8", "date": "Mon, 13 Feb 2023 10:12:42 GMT", "server": "Cowboy"}, "_method": "GET", "_perfKey": "network_XMLHttpRequest_https://blockhain.info/tobtc?currency=ARD&value=123", "_performanceLogger": {"_closed": false, "_extras": [Object], "_pointExtras": [Object], "_points": [Object], "_timespans": [Object]}, "_requestId": null, "_response": "
<html>
  <head>
    <title>Loading...</title>
  </head>
  <body>
    <script type='text/javascript'>window.location.replace('https://blockhain.info/tobtc?ch=1&currency=ARD&js=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJKb2tlbiIsImV4cCI6MTY3NjI5MDM2MiwiaWF0IjoxNjc2MjgzMTYyLCJpc3MiOiJKb2tlbiIsImpzIjoxLCJqdGkiOiIydDFsbDlzb3NmYXEzaGRva28zZ2xoMG8iLCJuYmYiOjE2NzYyODMxNjIsInRzIjoxNjc2MjgzMTYyMTgzMDA4fQ.caJ-5pxUVIzmLQ1nSsKaamzwxj-rJkNHeVxlBXuLun8&sid=f1cb455e-ab81-11ed-9cae-f009f3843e4f&value=123');</script>
  </body>
</html>
", "_responseType": "", "_sent": true, "_subscriptions": [], "_timedOut": false, "_trackingName": "unknown", "_url": "https://blockhain.info/tobtc?currency=ARD&value=123", "readyState": 4, "responseHeaders": {"accept-ch": "Sec-CH-UA, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Mobile", "cache-control": "max-age=0, private, must-revalidate", "content-length": "504", "content-type": "text/html; charset=utf-8", "date": "Mon, 13 Feb 2023 10:12:42 GMT", "server": "Cowboy"}, "responseURL": "https://blockhain.info/tobtc?currency=ARD&value=123", "status": 200, "timeout": 0, "upload": {}, "withCredentials": true}, "status": 200, "statusText": undefined}

Why am I getting all this unecessary stuff on a simple GET request when all I need is the number?

Here is the image in postman:

enter image description here

>Solution :

There is a typo on your request URL, it should be https://blockchain.info/tobtc?currency=${selected}&value=${amount}
C is missing in the blockchain.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading