Guest User

Untitled

a guest
Jan 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import {
  3. AppRegistry,
  4. StyleSheet,
  5. Text,
  6. View,
  7. Navigator,
  8. TouchableOpacity,
  9. Image,
  10. TextInput,
  11. TouchableHighlight,
  12. Alert
  13. } from 'react-native';
  14.  
  15. import Button from 'react-native-button'
  16. import {Actions} from 'react-native-router-flux'
  17. import Home from './Home'
  18.  
  19. export class Weight extends Component{
  20. constructor(props) {
  21. super(props);
  22.  
  23. this.state = {
  24. data: '',
  25. data1:'',
  26. textinput:'',
  27. entryDate: '',
  28. systol:''
  29. }
  30.  
  31. componentDidMount(){
  32. this._onPressButtonGET();
  33. }
  34. _onPressButtonPOST(){
  35. fetch("url", {
  36. method: "POST",
  37. headers: {
  38. 'Accept': 'application/json',
  39. 'Content-Type': 'application/json',
  40. },
  41. body: JSON.stringify({
  42. "entryDate":"3/2/2017 2:00 AM",
  43. "systol": "120",
  44. "mobileType":"ANDROID",
  45. "userName":"menutest"
  46.  
  47. })})
  48. .then((response) => response.json())
  49. .then((responseData) => {
  50. Alert.alert(
  51. "Blood pressure data",
  52. "Blood pressure data - " + JSON.stringify(responseData)
  53. )
  54. })
  55. .done();
  56. }
  57.  
  58. _onPressButtonGET () {
  59. fetch("url", {
  60. method: "POST",
  61. headers: {
  62. 'Accept': 'application/json',
  63. 'Content-Type': 'application/json',
  64. },
  65. body: JSON.stringify({"mobileType":"ANDROID","userName":"menutest"})})
  66. .then((response) => response.json())
  67. .then((responseData) => {
  68. this.setState({ data: JSON.stringify(responseData) })
  69. })
  70.  
  71. .done();
  72. }
  73. render(){
  74. return(
  75. <View>
  76. <TouchableHighlight onPress={this._onPressButtonPOST}>
  77. <Text>Add</Text>
  78. </TouchableHighlight>
  79.  
  80.  
  81. <TouchableHighlight onPress={this._onPressButtonGET.bind(this)}>
  82. <Text>show</Text>
  83. </TouchableHighlight>
  84.  
  85. <Text>{this.state.responseData.entryDate}</Text>
  86. <Text>{this.state.responseData.systol}</Text>
  87.  
  88. </View>
  89. );
  90. }
  91. }
  92.  
  93. module.exports = Weight;
  94.  
  95. <Text>{this.state.entryDate}</Text>
Add Comment
Please, Sign In to add comment