Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

54
Vistas
Getting Data from the Frontend & CORS

i´m stuck at a little demo project from udemy with django and api calls. I have this in main.js and I want to get array of object and not just a json list in console.

let projectsUrl = 'http://127.0.0.1:8000/api/projects/'

let getProjects = () => {
   
    fetch(projectsUrl)
        .then(response => response.json())
        .then(data => {
            console.log(data)
            buildProjects(data)
        })
   
}

let buildProjects = (projects) => {
    
    let projectsWrapper = document.getElementById('testz')

    for (let i = 0; projects.lenght > i; i++){
        let project = projects[i]
        console.log(project)
    }
}


getProjects()

The result :

Console Log

and the result should be something like this :

Console Log

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is a typo.

change

projects.lenght

to

projects.length
7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.