Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import {StyleSheet, View, Text, TextInput, ActivityIndicator, Image } from 'react-native';
- import AsyncStorage from '@react-native-community/async-storage';
- import { Button,CardItem } from 'native-base'
- import Axios from 'axios';
- class Promotions extends Component {
- constructor(props) {
- super(props);
- this.state = {
- isLoading: false,
- id:'',
- treatment_id: '',
- title: '',
- desc: '',
- image:'',
- token: '',
- promotionsSource: []
- }
- }
- async componentDidMount() {
- const token = await AsyncStorage.getItem('token')
- Axios({
- method: 'get',
- url: 'http://192.168.56.1/vzuu/public/api/promotions',
- dataType: 'json',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer ' + token,
- },
- })
- .then(response => {
- var transaction = [];
- for (var i = 0; i < response.data.results.promotions.length; i++) {
- transaction.push([
- response.data.results.promotions[i].id,
- response.data.results.promotions[i].treatment_id,
- response.data.results.promotions[i].title,
- response.data.results.promotions[i].desc,
- response.data
- ]);
- }
- this.setState({
- promotionsSource: promotions,
- })
- });
- console.log(this.state.data);
- Axios({
- method: 'get',
- url: 'http://192.168.56.1/vzuu/public/api/treatments',
- dataType: 'json',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- // 'Authorization': 'Bearer ' + token,
- },
- })
- .then(response => {
- this.setState({ promotionsSource: response.data.results.treatments });
- });
- console.log(this.state.data);
- }
- render() {
- if (this.state.isLoading) {
- return (
- <View style={{flex: 1, paddingTop: 20}}>
- <ActivityIndicator />
- </View>
- );
- }
- return(
- <View>
- <CardItem>
- <Image />
- </CardItem>
- <CardItem>
- <Text />
- </CardItem>
- </View>
- )
- }
- }
- export default Promotions;
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center'
- },
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement