I'm Using ionic with parse and I'm trying to access the children from the res.results
I still get the undefined error
unfollow(){
this.url ='https://meet-up-zionnite.c9users.io/app1/classes/friendslist';
this.http.get(this.url, {headers : this.headers}).map(res => res.json()).subscribe(res =>{
this.localstorage.set('friendslist_db_detail',res);
console.log(res.results.my_id);
if(res.results == this.my_id){
console.log('hey over here');
}else{
console.log("Not Match");
}
});
}
This is what I need to access:
1) ObjectId
2) my_id
3) f_id
wow, i receive a help from one of my online tutor and it solved it
here is what have been missing
console.log(res.results[0]['my_id']);
Related
I have a block of code that I found online and it seems to be working and not working at the same time. I think its probably my lack of understanding but I cant seem to get it to work the way I want it.
selectPicture() {
let context = imagepicker.create({
mode: "single" // use "multiple" for multiple selection
});
var imageBase64
context
.authorize()
.then(function() {
return context.present();
})
.then(function(selection) {
selection.forEach(function(selected) {
imageSourceModule.fromAsset(selected).then((imageSource) => {
imageBase64 = imageSource.toBase64String("jpg",60);
console.log("Image saved successfully!")
console.log(imageBase64)
console.log("test test") //runs fine
this.image = "~/assets/images/account/camera.png" //cant seem to run
console.log("test test 2")
}).catch(function (e) {
// process error
console.log("got error 1")
});
})
}).catch(function (e) {
// process error
console.log("got error 2")
});
},
Within the imageSourceModule.fromAsset(selected).then((imageSource), I was trying to save the base64 info in another variable but cant seem to do anything within other than console log a string. When I run this.image = "~/assets/images/account/camera.png" (just a placeholder, even calling a method does not work too) for example it catches an error.
What could the problem be? thank you!
UPDATE
I changed console.log("got error 1") to log the actual update and what i got was:
undefined is not an object (evaluating 'this.image = "~/assets/images/account/camera.png"')*
I now think that theres a problem with my understanding calling variable outside. My variable 'image' is within the script at
data() {
return {
image : ""
}
}
first of all check what this variable is, because you do not use es6 arrow functions, so this is probably not the vue instance.
the second thing: when you change vue-variables asynchronously use the $set method, like: this.$set(this, 'image', '~/assets/images/account/camera.png')
I am trying to use react-native-fbsdk in my react-native app. It was working fine untill yesterday. But, today it gives a weird error stating RCTJSONStringify() encountered the following error: Invalid type in JSON write (NSURL).
RN v0.42.0
Here is my code:
_fbAuth(error, result) {
if (error) {
console.log("error");
alert("login has error: " + result.error);
} else if (result.isCancelled) {
console.log("login cancelled");
alert("login is cancelled.");
} else {
AccessToken.getCurrentAccessToken().then((data) => {
console.log("login success");
console.log(data.accessToken.toString());
let accessToken = data.accessToken;
alert(data.accessToken.toString());
const responseInfoCallback = (error, result) => {
if (error) {
console.log(error);
} else {
console.log(result);
}
}
const infoRequest = new GraphRequest(
'/me',
{
accessToken: accessToken,
parameters: {
fields: {
string: 'email,name,first_name,middle_name,last_name'
}
}
},
responseInfoCallback
);
// Start the graph request.
new GraphRequestManager().addRequest(infoRequest).start();
});
}
}
render() {
console.log("in new render");
return (
<View style={styles.container}>
<LoginButton
publishPermissions={["publish_actions"]}
onLoginFinished={this._fbAuth}
onLogoutFinished={() => alert("logout.")}/>
</View>
);
}
The error information printed in debugger:
I get the above error while calling the graphAPI in the function responseInfoCallback. Any ideas what is happening ?
Update 1:
This error happens only when remote debugger is turned on!! Else it is not happening. But without remote debugger, I cannot proceed with developing the app. Are there any other methods to see log statements of react-native app other than remote debugger ?
Update 2:
The RCTJSONStringify() error happens only behind proxy. And also https fetch calls does not work under proxy. I tested in an open network, it works fine. I guess, it is to add some proxy information to RN app. I think it is related to APP transport security
If you turn the debugger off, you can see the proper error in the XCode console. Access it from Xcode menu View/Debug Area/Activate console, if it's not enabled automatically.
I have integrated the react-native-fbsdk library and getting user profile info such as name, middle name etc except email
i have tried readPermissions={["email,"public_profile","friends"]}
Then too not getting email
Any help would be appreciated.
Thanks in advance
I'm facing the same issue and it looks like the only workaround is using the LoginManager class provided by react-native-fbsdk.
import {
LoginManager,
} from 'react-native-fbsdk';
const _fbLogin = () => {
LoginManager.logInWithReadPermissions(['public_profile', 'email']).then(
(result) => {
if (result.isCancelled) {
alert('Login cancelled');
} else {
alert('Login success with permissions: ' + JSON.stringify(result));
}
},
(error) => {
alert('Login fail with error: ' + error);
}
);
}
And you can try using that _fbLogin function as an event handler for a custom button. I did not find how to use it with the blue, out of the box facebook Log in button.
Hope it helps!
readPermissions has now been replaced with permissions
<LoginButton
permissions={["email", "user_friends", "public_profile"]}
onLoginFinished={this._onFacebookLoginFinished.bind(this)}
onLogoutFinished={this._onFacebookLogoutFinished.bind(this)}
/>
Once you've completed a login and have an access token, you need to use the Graph API https://github.com/facebook/react-native-fbsdk#graph-api to retrieve data
you can find explaination for it here
I test relay, and I use relay-local-schema for test graph-ql request in client memory.
All are good, and when the sendQueries method is called I fetch the good data. I can check this in debug.
But after, I have this error message :
RelayQueryWriter: Unexpectedly encountered undefined in payload. Cannot set root record client:4122484501 to undefined.
I don't understand the error message and it is very difficult for me to understand the problem.
I use typescript and tsx extentention.
thanks in advance, if you have any Idea for my problem
EDIT : RESOLVED
I make a mistake with the promise in the sendQuery method
with this all is better:
sendQueries(queryRequests) {
return Promise.all(
queryRequests.map(queryRequest =>
graphql.graphql(
this._schema,
queryRequest.getQueryString(),
this._rootValue,
queryRequest.getVariables()
).then(result => {
if (result.errors) {
queryRequest.reject(new Error("..."));
} else {
queryRequest.resolve({response: result.data});
}
})
)
);
}
I make a mistake with the promise in the sendQuery method.
I make a mistake with the promise in the sendQuery method
with this all is better:
sendQueries(queryRequests) {
return Promise.all(
queryRequests.map(queryRequest =>
graphql.graphql(
this._schema,
queryRequest.getQueryString(),
this._rootValue,
queryRequest.getVariables()
).then(result => {
if (result.errors) {
queryRequest.reject(new Error("..."));
} else {
queryRequest.resolve({response: result.data});
}
})
)
);
}
But I don't understand why I haved this error message : Relay - RelayQueryWriter: Unexpectedly encountered undefined in payload
I use restangular to create albums,
createAlbum:function(obj){
albumlist.post(obj.data).then(function(res){
console.log(res)
obj.success(res)
},function(err){
obj.error(err)
})
}
and I call the service like this
$scope.createAlbum = function(){
albumService.createAlbum({
data:$scope.newalbum,
success:function(data){
$scope.albumlist.push(data)
},
error:function(err){
alert('error'+err.status)
}
})
}
but after the album successfully posted the console.log(res) always undefined , any thing wrong with my code?
Check the network tab to see if your POST request is actually returning something. If it's not, then that's the issue :).
Otherwise it should log something.