I'm trying to change two dates which determine a range of days, on those days we can see which asteroids where closeby earth. I'm using axios to make the request to my api and I have to params that need to change with an html input but I'm not able to change them properly, or I can't find the way, can someone help me? thanks!!!!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pruebas API</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="js/api_nasa.js"></script>
<label for="Fecha comienzo">Fecha de comienzo aaaa/mm/dd</label>
<div></div>
<input type="text" id="start_date" name="Fecha comienzo"></input>
<button onclick="actualizarFecha()">Entrar</button>
</body>
</html>
And my javascript
function actualizarFecha(){
var input = document.getElementById("start_date").value;
console.log(input)
buscarAsteroide();
// return input;
buscarAsteroide(input)
}
const buscarAsteroide = async(fechaInicio, fechaFinal) => {
console.log(fechaInicio)
try {
const respuesta = await axios.get('https://api.nasa.gov/neo/rest/v1/feed?', {
params: {
start_date: '2021-04-09',
end_date: '2021-04-10',
api_key: 'cant't show u this',
}
})
console.log(respuesta.data);
} catch(error) {
console.log(error);
}
}
buscarAsteroide();
once again, thanks!