JSON de ejemplo:
[ { "sha": "0bf21a1dc1c03f11bb44ac32a65c17b5857b020c", "node_id": "MDyODE2MY6Q29tbWl0NzYGJmMjFjYzE3YjUwM2YxMDk6MWJiNDRhYzMyYTFkYzFhNjU4NTdiMDIwYw==", "commit": { "author": { "name": "Max Mustermann", "email": "max@mustermann.at", "date": "2016-12-12T19:56:46Z" }, "committer": { "name": "GitHub", "email": "noreply@github.com", "date": "2016-12-12T19:56:46Z" }, "message": "Update README.md", ... ¿Cómo obtengo la fecha de confirmación -> autor -> fecha en javascript?
Mi prueba:
fetch("https://api.github.com/repos/schletz/3KanalAdWandler/commits", requestOptions) .then(response => response.text()) .then(result => console.log(result.commit.author.date)) .catch(error => console.log('error', error)); Lo que obtengo: TypeError: Cannot read properties of undefined (reading 'author')
El result parece ser una matriz, por lo que deberá incluir el índice de la matriz. console.log(result[0].commit.author.date) .