I am trying to use a Node.JS application to make and receive API requests. It does a get request to another server using Axios with data it receives from an API call it rece
axiosTest()
is firing asynchronously
and not being waited for.
A then()
function
needs to be hooked up afterwards in order to capture the response
variable
(axiosTestData
).
See Promise for more info.
See Async to level up.
// Dummy Url.
const url = 'https://jsonplaceholder.typicode.com/posts/1'
// Axios Test.
const axiosTest = axios.get
// Axios Test Data.
axiosTest(url).then(function(axiosTestResult) {
console.log('response.JSON:', {
message: 'Request received',
data: axiosTestResult.data
})
})