I will ask again. Hope someone who has experienced the same issue offer me some help.
Background: to build a translation app from Swedish to English with ReactApp.
Issue: when access an open URL with axios.get(
https://dictapi.lexicala.com/test)
, I am able to get data, but if replace with axios.get(
https://dictapi.lexicala.com/search?source=global&language=sv&text=${keyWord})
, resulted in GET https://dictapi.lexicala.com/search?source=global&language=sv&text=asdf 401
I suppose I need to find a way to embed my user credentials for api provider in my ReactApp code, everytime before use axios.get(
https://dictapi.lexicala.com/search?source=global&language=sv&text=${keyWord})
, I should make a login act to this api server. Because, I can access api server with URL in chrome, e.g. https://dictapi.lexicala.com/search?source=global&language=es&text=azul
due to the fact chrome saved my user credentials.
Please indicate how to search the right question for sovling this problem? I am not expert with ReactJS and neither am I an English native speaker. What techniques should I refer to ?
CodePudding user response:
The question is not related to React. It's related to a network call. Looking at https://dictapi.lexicala.com looks like it requires a basic auth. So probably what do you want to check is that question: How to send Basic Auth with axios
CodePudding user response:
I haven't signed up for the service so I cant analyse the API, but I imagine you're assigned an API key - you'll want to either send this via url parameters or headers, depending on how the api works. These are both pretty easy to do with axios basic auth.