简体   繁体   中英

Unhandled Rejection (TypeError): Object(...) is not a function

I am importing getEstimateSummary data from another file and handling with await but while passing in sprintDay function it's showing me an object is not a function when I am paasing into my second function and here is my code

import React from "react";
import getEstimateSummary from "../../service/requirementService";



const SprintDay = async () => {
  const res = await getEstimateSummary();

  const fliterOut = [
    "Estimated_minutes",
    "To_do_stories",
    "Requirement_complete",
    "Remaining_User_Stories",
    "Original_hours",
    "total_user_stories",
  ];
  console.log("filterDay", fliterOut);

  const keys = Object.keys(res[0]).filter((ele) => !fliterOut.includes(ele));
  console.log("keys day", keys);

  const data = res.map((item) => [
    item.TrackChange,
    ...keys.map((ele) => item[ele]),
  ]);
};

const Second = () => {
  SprintDay();

  return (
    <div className="second">
      <Navbar variant="light" bg="light" border-bottom border-dark>
        <Navbar href="#home">Home/Sprint Requirement</Navbar>
         <Navbar.Collapse id="basic-navbar-nav">
          <Nav className="mr-auto">
            <Button variant="secondary">Track Changes</Button>
            <NavDropdown title="Day"></NavDropdown>
          </Nav>
          <Form inline>
            <Button variant="secondary" className=" mr-sm-2">
              Last Updated: 5 July,2020
            </Button>
            <Button variant="secondary"> Next Refresh: 6 July,2020</Button>
          </Form>
        </Navbar.Collapse>
      </Navbar>
    </div>
  );
};

export default Second;

This is my requirement service file

export const getEstimateSummary = async () => {
  try {
    const url = `${apiEndpoint}/EstimateSummary/?token=${token}`;
    const res = await axios.get(url);
    return res.data;
  } catch (err) {
    return err;
  }
};

You are using a named export while importing your function as a default import.

Try changing your import line to

import { getEstimateSummary} from '../../requirementService';

or your export line to:

export default async () => {
  try {
    const url = `${apiEndpoint}/EstimateSummary/?token=${token}`;
    const res = await axios.get(url);
    return res.data;
  } catch (err) {
    return err;
  }
}; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM