TypeError: results.map is not a function Function.renderemployeeTable

I was trying to display api data using reactJs Application. i used the following code but i keep getting the following error

TypeError: results.map is not a function Function.renderemployeeTable

export class FetchData extends Component { static displayName = FetchData.name;

    constructor(props) {
        super(props);
        this.state = { results: [] };
    }

    componentDidMount() {
           fetch('urll', {
            method: 'GET',
            headers: {
                'api-key': 'api-key'  
            }
        })
            .then(results => results.json())
            .then(data => this.setState({ results: data }));
    }
    static renderemployeeTable(results) {
        return (

            <div class="container-fluid" class="row" fluid={true}>
                {
                    results.map(results =>
                        <div class="col-sm-3" key={results.Employee_Number}>
                            <div class="card our-team" >
                                <div class="card-body">

                                    <p class="card-text">{results.first_name}</p>
                                    <p class="card-text">{results.last_name}</p>
                                </div>
                            </div>
                            <a href="#" class="btn btn-primary">Detail</a>
                        </div>
                    )
                }
            </div>
        );
    }
    render() {
        let contents = this.state.loading
            ? <p><em>Loading...</em></p>
            : FetchData.renderemployeeTable(this.state.results);

        return (
            <div>
                <h1 id="tabelLabel" >-</h1>


                {contents}
            </div>
        );

    }
    async populateemployeeData() {
        const response = await fetch('table');
        const data = await response.json();
        this.setState({ results: data, loading: false });
    }
}

but i get this error message

TypeError: results.map is not a function
Function.renderemployeeTable

This is the output of console.log(results).

"data": {
 "Table": [
 {
 "id": 14258,
 "first_name": "yibgeta",
 "last_name": "solans",...
  }]}],

Now it will work------

  constructor(props) {
    super(props);
    this.state = { results: [] };
}

componentDidMount() {
       fetch('http://web.api.services/api/v2/tultula/employees/all', {
        method: 'GET',
        headers: {
            'api-key': '7cefc4163dula77bf0f41ba741c'  
        }
    })
        .then(results => results.json())
        .then(data => this.setState({ results: data }));
}



  render() {
              if(this.state.result != null && this.state.result!= undefined){
   return (

        <div class="container-fluid" class="row" fluid={true}>
            {
                this.state.results.map(results =>
                    <div class="col-sm-3" key={results.Employee_Number}>
                        <div class="card our-team" >
                            <div class="card-body">

                                <p class="card-text">{results.first_name}</p>
                                <p class="card-text">{results.last_name}</p>
                            </div>
                        </div>
                        <a href="#" class="btn btn-primary">Detail</a>
                    </div>
                )
            }
        </div>
    );}

    let contents = this.state.loading
        ? <p><em>Loading...</em></p>
        : FetchData.renderemployeeTable(this.state.results);

    return (
        <div>
            <h1 id="tabelLabel" >-</h1>


            {contents}
        </div>
    );

}
async populateemployeeData() {
    const response = await fetch('table');
    const data = await response.json();
    this.setState({ results: data, loading: false });
  }
}

TypeError:results.map不是函数Function.renderemployeeTable, renderemployeeTable 导出类FetchData扩展了组件static displayName FetchData .name. TypeError: results.map is not a function Function. Since you do not specify types for anything and it is not really clear (not even for a human-reader) that items is an Array, you should explicitly tell TypeScript to use it as an array. You use Type Assertion for that purpose. Should be something like: (items as Array<YourArrayElementType>).map(/* ..


Did you have ever try to write down like this?

data => this.setState({
  results: data.Table
})

Or

results.Table.map(result => ...)

TypeError: items.map is not a function React � Issue #3388 � reduxjs , import React from 'react' import { BrowserRouter as Router, Route } from 'react- router-dom'; import LoginForm from './LoginForm'; class App� Goals I did query a Realm collection Expected Results I expect to be able to execute .map() or .forEach() methods on Realm results. Actual Results When I console.log() the realm results I see well that the type of the object is a result.


Try

{
    results.Table && results.Table.map( result =>...)
}

This will ensure that the array exists and then you can use map function on it.

TypeError: .map is not a function (React js) - JavaScript, Am a newbie in react, so pardon me if am unable to fully explain the problem am facing, but after google searching, I came to understand that� I'm submitting a [x] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here


Try in this way:-

import React, { Component } from "react";

class Example extends Component {
  constructor(props) {
    super(props);
    this.state = { results: [] };
  }

  componentDidMount() {
    fetch("url", {
      method: "GET",
      headers: {
        "api-key": "api-key"
      }
    })
      .then(results => results.json())
      .then(data => this.setState({ results: data }));
  }

  renderemployeeTable(results) {
    return (
      <div className="container-fluid" className="row" fluid={true}>
        {results.map(results => (
          <div className="col-sm-3" key={results.Employee_Number}>
            <div className="card our-team">
              <div className="card-body">
                <p className="card-text">{results.first_name}</p>
                <p className="card-text">{results.last_name}</p>
              </div>
            </div>
            <a href="#" className="btn btn-primary">
              Detail
            </a>
          </div>
        ))}
      </div>
    );
  }
  render() {
    let contents = this.state.loading ? (
      <p>
        <em>Loading...</em>
      </p>
    ) : (
      this.renderemployeeTable(this.state.results)
    );

    return (
      <div>
        <h1 id="tabelLabel">-</h1>

        {contents}
      </div>
    );
  }
  async populateemployeeData() {
    const response = await fetch("table");
    const data = await response.json();
    this.setState({ results: data, loading: false });
  }
}

export default Example;

Ошибка типа: results.map не является функцией Function , Function.renderemployeeTable класс экспорта FetchData extends Component {static displayName TypeError: results.map is not a function Function. I try to save this data.. Each property is transformed in getters and setters by Vue.js save { let scheduleRequests = [] self.schedule.forEach(it => { scheduleRequests.push(self.saveEventSchedule({ // <-- VUEX ACTION title: it.title,


Reactjs (this.state.data.map) is not a function, map) is not a function. Posted 2 years ago by mlazuardy. well i follow the tutorial from internet to list and key data with laravel, but it� const boxesWithText = results. map (in promise) TypeError: faceapi.draw.AgeAndGender is not a function at script.js:32. drawDetection is not a function..


Jammming, Jammming | Type error: this.props.tracks.map is not a function I'm not seeing how this isn't proper use of the map() . Component { render () { return ( <div className="SearchResults"> <h2>Results</h2> <TrackList� Returns : Returns a list of the results after applying the given function to each item of a given iterable (list, tuple etc.) NOTE : The returned value from map() (map object) then can be passed to functions like list() (to create a list), set() (to create a set) .


[REACT] this.state.array map is not a function - JavaScript, then i've a function that update this.setState on an Array with some data i get from props but when on render() { return( this.state.card.map((a,� TypeError: Cannot read property 'results' of undefined Note that I am assuming the function that calls fetch() is inside your class. You can do what you want with