Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import {
- AppRegistry,
- StyleSheet,
- Text,
- View,
- Navigator,
- TouchableOpacity,
- Image,
- TextInput,
- TouchableHighlight,
- Alert
- } from 'react-native';
- import Button from 'react-native-button'
- import {Actions} from 'react-native-router-flux'
- import Home from './Home'
- export class Weight extends Component{
- constructor(props) {
- super(props);
- this.state = {
- data: '',
- data1:'',
- textinput:'',
- entryDate: '',
- systol:''
- }
- componentDidMount(){
- this._onPressButtonGET();
- }
- _onPressButtonPOST(){
- fetch("url", {
- method: "POST",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- "entryDate":"3/2/2017 2:00 AM",
- "systol": "120",
- "mobileType":"ANDROID",
- "userName":"menutest"
- })})
- .then((response) => response.json())
- .then((responseData) => {
- Alert.alert(
- "Blood pressure data",
- "Blood pressure data - " + JSON.stringify(responseData)
- )
- })
- .done();
- }
- _onPressButtonGET () {
- fetch("url", {
- method: "POST",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({"mobileType":"ANDROID","userName":"menutest"})})
- .then((response) => response.json())
- .then((responseData) => {
- this.setState({ data: JSON.stringify(responseData) })
- })
- .done();
- }
- render(){
- return(
- <View>
- <TouchableHighlight onPress={this._onPressButtonPOST}>
- <Text>Add</Text>
- </TouchableHighlight>
- <TouchableHighlight onPress={this._onPressButtonGET.bind(this)}>
- <Text>show</Text>
- </TouchableHighlight>
- <Text>{this.state.responseData.entryDate}</Text>
- <Text>{this.state.responseData.systol}</Text>
- </View>
- );
- }
- }
- module.exports = Weight;
- <Text>{this.state.entryDate}</Text>
Add Comment
Please, Sign In to add comment