Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29594

React-native using native module and passing to app, cannot format into json object

$
0
0

I have implemented Java library to my React-native app with Native Modules, After finally being able to grab data in the app, I cannot convert it into Json object, have no idea why. When I pass it to my app, it looks like this:

{"data":{"pictureGroup":[],"checkDigit":4},"className":"someclassname"}

So I tried to parse it by have failed, all time get's response like:

Possible Unhandled Promise Rejection (id: 0): TypeError: res.parse is not a function _callee$@http://localhost:8081/App.bundle?platform=android&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:58:33 tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26922:19 invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27098:32 defineIteratorMethods/http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26965:23 tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26922:19 invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26998:30 invoke/<@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27008:21 tryCallOne@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:28860:14 handleResolved/<@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:28961:27 setImmediate/id<@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:32510:21 _callTimer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:32400:9 _callImmediatesPass@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:32436:19 callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:32654:14 __callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2719:16 flushedQueue/<@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2505:18 __guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2702:13 flushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2504:14 invokeCallbackAndReturnFlushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2497:21 parcelRequire<.sYUNhttp://localhost:8081/debugger-ui/debuggerWorker.cff11639.js:4:902

Here is my code:

import React from 'react';import {View, Text, TouchableOpacity} from 'react-native';import DocumentReaderModule from './DocumentReaderExample';// prettier-ignoreclass App extends React.Component {  constructor(props) {    super(props);    this.state = {      image: '',    };  }  test = async () => {      let res = await DocumentReaderModule.CaputeDocument();      console.log(res)      console.log(res.parse())  };  render() {    return (<View><TouchableOpacity onPress={() => this.test()}><Text>Click me</Text></TouchableOpacity></View>    );  }}export default App;

Viewing all articles
Browse latest Browse all 29594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>