我收到此错误,请帮助我无法读取未定义的属性“地图”

时间:2019-11-12 07:41:48

标签: reactjs api maps axios

import React, {
  Component
} from "react"

import axios from 'axios';
import ProductMain from './../ProductMain'
class Home extends Component {
  constructor(props) {
    super(props)
    this.state = {
      articles: []
    }
  }

  componentDidMount() {
    axios.get('http://roocket.org/api/products')
      .then(response => {
        const {
          current_page,
          data
        } = response.data.data.data;
        this.setState({
          articles: data
        })
        console.log(response)
      })
      .catch(error => {
        console.log(error)
      })

  }

  render() {
    return (
      <div className="jumbotron rtl">
        <div className="container">
          <h1 className="display-3"></h1>
          <p>While the idea of heating tobacco (instead of burning it) has been around for more than two decades, it took years of research and development to create a product that is satisfying to adult consumers. Around 8.8 million consumers have already chosen
            to switch from cigarettes to this product: our tobacco heating system IQOS. At the heart of IQOS are sophisticated electronics that heat specially designed heated tobacco units. IQOS heats the tobacco just enough to release a flavorful nicotine-containing
            tobacco vapor but without burning the tobacco. Here’s the key point: the tobacco in a cigarette burns at temperatures in excess of 600°C, generating smoke that contains high levels of harmful chemicals. But IQOS heats tobacco to much lower temperatures,
            up to 350°C, without combustion, fire, ash, or smoke. The lower temperature heating releases the true taste of heated tobacco. Because the tobacco is heated and not burned, the levels of harmful chemicals are significantly reduced compared to cigarette
            smoke. What is there? A nicotine-containing vapor – not smoke – that makes IQOS a smoke-free product that is appealing to smokers</p>
        </div>
        <div className="row rtl">
          {this.state.articles.map((product , index)=>
          <ProductMain product={product}key={index}/>)}
        </div>
      </div>
    )
  }
}
export default Home

1 个答案:

答案 0 :(得分:0)

请添加默认值作为空数组

Guid                                AttrName    AttrValue
00000000-0000-0000-0000-000000000000    2003    Some text
00000000-0000-0000-0000-000000000000    2004    0
00000000-0000-0000-0000-000000000000    2006    0
00000000-0000-0000-0000-000000000000    2008    0
00000000-0000-0000-0000-000000000000    2011    0
00000000-0000-0000-0000-000000000000    2120    0
705b30ab-53b0-42ee-bb98-6d80daae2e18    2121    0
705b30ab-53b0-42ee-bb98-6d80daae2e18    2297    0
705b30ab-53b0-42ee-bb98-6d80daae2e18    2298    0
705b30ab-53b0-42ee-bb98-6d80daae2e18    2299    0
705b30ab-53b0-42ee-bb98-6d80daae2e18    2805    0
705b30ab-53b0-42ee-bb98-6d80daae2e18    8501    0
705b30ab-53b0-42ee-bb98-6d80daae2e18    12004   0
705b30ab-53b0-42ee-bb98-6d80daae2e18    13266   0
705b30ab-53b0-42ee-bb98-6d80daae2e18    13282   0