Save data in phppgadmin Bank in React Native

0

I'm trying to save data in a PostgresSql database phppgadmin, I'm using React Native, and an API in PHP.

React code:

import React, { Component, Scene} from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  TextInput,
  View,
  Button,
  AppRegistry

} from 'react-native';
let getAmbiente = async () => await (await fetch("http://200.145.153.163/houzin/mobile/api/listarAmbientes.php")).json();
type Props = {};
export default class CenaHome extends Component<Props> {
  constructor() {
    super();
    this.state = {ambientes: []};
  }
  static navigationOptions = 
  {
    title: 'Home'

  };
  render() {
    return (
      <View>
        <Button 
        onPress = {
          async () => this.setState({ambientes: await getAmbiente()})
        }
        title="Carregar ambientes"
        color = "#841584"
        />

        <Text>{navigator.userAgent}</Text>
        {this.state.ambientes.map(({nome, codigo}) => <Text key={codigo}>{nome}</Text>)}
        <TextInput onChangeText={nome => this.setState({ambiente: nome})} />
        <Button title="Salvar" color="#841584" onPress={() => fetch("http://200.145.153.163/houzin/mobile/api/salvarAmbiente.php?" + new URLSearchParams({nome: this.state.ambiente}))} />
      </View>

    );
  }
}

const styles = StyleSheet.create({

});

AppRegistry.registerComponent('CenaHome', () => CenaHome);

error:

  

Can not find variable: URLSearchParams   onPress       index.delta?platform=android&dev=true&minify=false:79120:112   touchableHandlePress       index.delta?platform=android&dev=true&minify=false:39783:47   _performSideEffectsForTransition       index.delta?platform=android&dev=true&minify=false:39397:36   _receiveSignal       index.delta?platform=android&dev=true&minify=false:39330:46   touchableHandleResponderRelease       index.delta?platform=android&dev=true&minify=false:39215:26   invokeGuardedCallback       index.delta?platform=android&dev=true&minify=false:5780:21   invokeGuardedCallback       index.delta?platform=android&dev=true&minify=false:5849:40   invokeGuardedCallbackAndCatchFirstError       index.delta?platform=android&dev=true&minify=false:5852:54   executeDispatch       index.delta?platform=android&dev=true&minify=false:6023:64   executeDispatchesInOrder       index.delta?platform=android&dev=true&minify=false:6043:26   executeDispatchesAndRelease       index.delta?platform=android&dev=true&minify=false:6138:35   executeDispatchesAndReleaseTopLevel       index.delta?platform=android&dev=true&minify=false:6151:43   forEachAccumulated       index.delta?platform=android&dev=true&minify=false:6128:22   runEventsInBatch       index.delta?platform=android&dev=true&minify=false:6239:29   runExtractedEventsInBatch       index.delta?platform=android&dev=true&minify=false:6248:25          index.delta?platform=android&dev=true&minify=false:7279:36   batchedUpdates       index.delta?platform=android&dev=true&minify=false:15062:22   batchedUpdates       index.delta?platform=android&dev=true&minify=false:7199:33   _receiveRootNodeIDEvent       index.delta?platform=android&dev=true&minify=false:7278:23   receiveTouches       index.delta?platform=android&dev=true&minify=false:7308:34   __callFunction       index.delta?platform=android&dev=true&minify=false:4065:49          index.delta?platform=android&dev=true&minify=false:3835:31   __guardSafe       index.delta?platform=android&dev=true&minify=false:4027:13   callFunctionReturnFlushedQueue       index.delta?platform=android&dev=true&minify=false:3834:21   My API:

 <?php
    header("Access-Control-Allow-Origin: *");
    header('Content-Type: application/json');
    $con = pg_connect("host=localhost dbname=houzion user=houzion password=bj2fF4 port=5432");
    $query = pg_query_params($con, 'INSERT INTO ambiente (nome) VALUES ($1)', [$_GET['nome']]);
?>
    
asked by anonymous 07.07.2018 / 19:41

0 answers