Answer the question
In order to leave comments, you need to log in
Why is the Axios get request not working?
There is a server address to which requests should be sent: http://tmgwebtest.azurewebsites.net/api/textstrings/{id }, where {id} is the string ID.
The row ID is an integer and can take values in the range from 1 to 20 (the values "005", "05" and "5" are equivalent).
A GET request to this address should return JSON with the following structure {"text":"Some text here."} (the text field contains the search string).
To authenticate with the server, add the "TMG-Api-Key" header with the value "0J/RgNC40LLQtdGC0LjQutC4IQ==" to the request.
Here is my code
async function fetchApi() {
const id = 15
const url = `http://tmgwebtest.azurewebsites.net/api/textstrings/${id}`
await axios.get(
url,
{headers: {
"TMG-Api-Key" : "0J/RgNC40LLQtdGC0LjQutC4IQ=="
}
}
)
.then((response) => {
const respons = response.data;
console.log(respons);
},
(error) => {
console.log(error);
}
);
}
Answer the question
In order to leave comments, you need to log in
https://stackoverflow.com/questions/42168773/how-t...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question