Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

315
Vistas
TypeError : post.map() is not a function

It will continuously showing this error that TypeError: post.map is not a function. please give me some appropriate answer guyz.

import React from "react";
import { useState } from "react";

function LoopThrough() {
const [post, setpost] = useState("");

function getDataFromApi() {
  // using axios method

  axios
    .get("https://jsonplaceholder.typicode.com/posts")
    .then((get) => {
      console.log(get.data);

      setpost(get.data);
    })
    .catch((error) => {
      console.log(error);
    });
}

const getdatafromjson = post.map((myobj) => {
  return (
    <div>
      <h2>{myobj.title}</h2>
    </div>
  );
});

return (
  <>
    <h2>Return Html using http methods</h2>

    <button onClick={getDataFromApi}>Get Data</button>

    {getdatafromjson}
  </>
);
}
export default LoopThrough;

Note : In this example , i want to get data from external Api using Axios method(language: React JS) and render it onto the display using react hooks and map() method but it doesnt work.

Error : TypeError: post.map() is not a function .

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda