Hi there,
I’ve read everything I can about this issue on these forums and on Stack Exchange, however, I cannot see where I am going wrong, or why my key isn’t being accepted.
I am desperate for help and feel like I’m just majorly overlooking something here
My goal is to visit localhost:3000/api/hello and have this send an axios.get request to the public data API’s ‘search all’ section using the q param “Just” while having my Rest API Key in the header for authorisation.
I have done the hosts file local host workaround mentioned here like so:
127.0.0.1 application.com
And have ensured “http://application.com” is in the Javascript Domains section of my key
I have attempted to do this in 3 different ways now.
-
Setting global axios auth & content-type headers for all requests and sending just params via axios.get to https://api.company-information.service.gov.uk/search
(Result: Authorization & Content-Type properly shown in err.equest._header, but error code 400) -
Setting axiosinstance config via axios.create with auth & content-type headers & q param then via axiosinstance.get to https://api.company-information.service.gov.uk/search
(Result: Authorization & Content-Type properly shown in err.request._header, but error code 400) -
Sending whole request, params & headers in a one-liner:
axios.get(apiUrl, {params: { q: searchterm }}, {headers: { ‘Authorization’:Basic ${apiKey}:
, ‘Content-Type’: ‘application/json’}})
(Result: Authorization & Content-Type NOT shown in err.request._header, & error code 401)
For #3, apiUrl = “https://api.company-information.service.gov.uk/search”
And searchterm = “Just”
I have tried base64 encoding my key first, btoa’ing it and tried it without the “:” to no avail.
I have attached an image of option 3 as that seems to have gotten me the closest so far.
Any help at all would be appreciated, I feel incredibly lost