SHARE
TWEET

Parse-ServerAppDemo-Error

anhhtz Feb 18th, 2020 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. // import { Parse } from 'parse/react-native'
  3. const Parse = require('parse/react-native')
  4. // import { AsyncStorage } from '@react-native-community/async-storage'
  5.  
  6.  
  7.  
  8. export default class App extends React.Component {
  9.   constructor(props) {
  10.     super(props)
  11.  
  12.     Parse.initialize("APP_ID",
  13.       "JS_KEY")
  14.     Parse.serverURL = 'https://parseapi.back4app.com/'
  15.     // Parse.setAsyncStorage(AsyncStorage)
  16.   }
  17.  
  18.   componentDidMount() {
  19.     /**
  20.      * Test part 1
  21.      */
  22.     var Test = Parse.Object.extend("Test");
  23.     var test = new Test();
  24.  
  25.     test.set("name", "test_name");
  26.  
  27.     test.save()
  28.       .then((obj) => {
  29.         alert('New object created with objectId: ' + obj.id);
  30.       }, (error) => {
  31.         console.debug('Failed to create new object, with error code: ' + error.message);
  32.       });
  33.  
  34.     /**
  35.      * Test part 2
  36.      */
  37.     let install = new Parse.Installation();
  38.     install.set("deviceType", 'navigator.userAgent');
  39.  
  40.     install.save().then((resp) => {
  41.       console.log('Created install object', resp);
  42.  
  43.       this.setState({
  44.         result: 'New object created with objectId: ' + resp.id
  45.       })
  46.     }, err => {
  47.       console.log('Error creating install object', err);
  48.  
  49.       this.setState({
  50.         result: 'Failed to create new object, with error code: ' + err.message
  51.       })
  52.     })
  53.   }
  54.  
  55.   render() {
  56.     return null
  57.   }
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top