Skip to content

Instantly share code, notes, and snippets.

@BunHouth
Created July 31, 2017 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BunHouth/61fe0f003da54bbf96505362bd0534e2 to your computer and use it in GitHub Desktop.
Save BunHouth/61fe0f003da54bbf96505362bd0534e2 to your computer and use it in GitHub Desktop.
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