Created
July 31, 2017 08:25
-
-
Save BunHouth/61fe0f003da54bbf96505362bd0534e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { StyleSheet, Text, View, ScrollView } from "react-native"; | |
import axios from "axios"; | |
export default class App extends React.Component { | |
state = { | |
data: [] | |
}; | |
async componentDidMount() { | |
await this.getTest(); | |
} | |
getTest() { | |
axios | |
.get("https://www.tosfund.com/api/v1/campaigns") | |
.then(({ data }) => { | |
this.setState({ data: data }); | |
}) | |
.catch(error => { | |
alet(error.message); | |
}); | |
} | |
render() { | |
const { data } = this.state; | |
return ( | |
<ScrollView style={{ marginTop: 64 }}> | |
{data.map((item, index) => | |
<View | |
key={index} | |
style={{ | |
borderBottomWidth: 1, | |
borderColor: "#ccc", | |
height: 45, | |
justifyContent: "center", | |
paddingLeft: 15, | |
paddingRight: 15 | |
}} | |
> | |
<Text>{item.name_en}</Text> | |
</View> | |
)} | |
</ScrollView> | |
); | |
} | |
} | |
const styles = StyleSheet.create({}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment