0

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 ?

2
  • there's a great resource freecodecamp.org/news/how-to-use-axios-with-react Commented Feb 1, 2022 at 11:40
  • Thank you, but it does not show me how to POST my usrname and password to API server to initiate a session. Commented Feb 1, 2022 at 14:36

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.