I have a function which works perfectly in Javascript on my iPhone simulator on the Mac. When i transfer this via Xcode to an physical iPhone handset, the .replace() function doesn't work. I get the error: TypeError: null is not an object (data.replace) not evaluating
await this.getAsyncStorage(this.state.username)
.then(data => this.setState({localname: data.replace(/\"/g, "") }) );
So i get a returned id ("hiuhiu22-sdwdw343-fgrh6576") from AsyncStorage when i supply the this.state.username
key. The replace()
strips "" off the ends of "hiuhiu22-sdwdw343-fgrh6576"
to get just hiuhiu22-sdwdw343-fgrh6576
, so that i can use localname
in another function, which MUST have them stripped off.
Why isn't it working on the actual iPhone?