Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

312
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!