Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react'
- import MapContainer from './MapContainer'
- import { getTest, getAll } from '../js/StationsAPI'
- class Main extends Component {
- constructor() {
- super()
- this.state = {
- stations: []
- }
- }
- componentDidMount() {
- this.getAllStations()
- }
- getAllStations() {
- let getAllPromise = new Promise(resolve => {
- resolve(
- getAll()
- )
- })
- const asyncGet = async () => {
- try{
- const stations = await getAllPromise.then(stations => stations)
- this.setState({ stations })
- } catch (e) {}
- }
- asyncGet()
- }
- render() {
- return <MapContainer stations={this.state.stations}/>
- }
- }
- export default Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement