why this fuction do not return anything for me. I think I have problem with axios.get.then(). So can you help to make it return message in then(reponse => ...)
The main question here is how can i save what function testConnection()
return into a variable message
to use it many time.
var axios = require('axios');
function testConnection() {
axios.get(`https://api.themoviedb.org/3/discover/movie`, {
params: {
api_key: '72f444fa3d547f8ab38bcc6d9b00ffd6',
sort_by: 'popularity.desc',
include_adult: false,
include_video: false,
with_genres: 28,
with_original_language: 'en',
},
}).then(response => {
if (response.length === 0) {
return "NOT OK";
}
return "OK";
})
}
var message = testConnection();
console.log(message);
Here is result when I run my code. enter image description here