Parse.com Javascript SDK using include, but not working - javascript

I'm trying to fetch data from a table called Book. Inside Book there's a Pointer<ParseUser> which holds the pointer of one user. The ParseUser has another pointer called Pais (which means Country in spanish). So I want to fetch every single info from any Book:
var query = new Parse.Query("Book");
query.include("user");
query.include("user.pais");
query.find({
success: function(books) {
response.success(books);
},
error: function(error) {
response.error({'resp': error.code, 'message': error.message});
}
});
and I don't get the objects, just the pointers:
Why ? I know it works ok when I call it in iOS or Android with include(String key) or includeKey: NSString* key.
Why doesn't it work with Javascript??
Thank you in advance.
Regards.
Rafael.
EDIT:
Oh and I just forgot... I've tried with:
query.include(["user"]);
and
query.include(["user", "user.pais"]);
I've seen some examples where developers used it.
SECOND EDIT:
The last thing I've used is fetch like:
Parse.Object.fetchAll(books, {
success: function(list) {
response.success(list);
},
error: function(error2) {
response.error({'resp': error2.code, 'message': error2.message});
},
});
But didn't work either.
This is starting to freak me out.
OUR WORKAROUND:
The workaround we're trying to do is fetching everything separately, and then returning back to the user together. This is not a good practice since a little change in the class in a future would ruin the whole function.
Is this a bug in the SDK ?

(This is a comment turned into an answer)
Just a thought because I recently had a problem with CloudCode that is quite similar to yours. What version of the JavaScript SDK are you using? I solved my problem by changing the version back to 1.4.2. It's just a shot in the dark in your case, but it might work.
Here is the thread where I described the problem and how to solve it by changing the SDK version.

Related

The remote endpoint could not be called, or the response it returned was invalid. (alexa, aws)

I'm currently getting into developing alexa-skills. This is in fact the 1st time I'm trying this and I kinda works out good so far. However, I stumbled upon a problem which seems to be wide-spreaded but I couldn't find an answer how to solve it.
First things first:
I started this skill by following a tutorial. It might be that this tutorial is outdated and therefore this error appears.
I created a skill from the scratch and it works to the part where the LaunchRequest is invoked:
As you can see, I get my response as expected. (works on the test-environment as well as on alexa itself). Now, when try to call an IntentRequest, I just get the error-message:
The remote endpoint could not be called, or the response it returned was invalid.
As I can tell from the picture / request, the correct intent-request is called (in my case getSubscriberCount ) - And this is the point where I have no idea anymore on how to resolve this problem.
To keep things short, this here is the JS-part for the Intent:
case "IntentRequest":
// Intent Request
console.log(INTENT REQUEST)
switch(event.request.intent.name) {
case "GetSubscriberCount":
var endpoint = "my url"
var body = ""
https.get(endpoint, (response) => {
response.on('data', (chunk) => { body += chunk })
response.on('end', () => {
var data = JSON.parse(body)
var subscriberCount = data.items[0].statistics.subscriberCount
context.succeed(
generateResponse(
buildSpeechletResponse(`Du hast momentan ${subscriberCount} Abonnenten`, true),
{}
)
)
And this is causing my problems. To test what exactly is wrong, I tried the following:
Called the endpoint in my browser --> Correct output
Adjusted the "response" to the minimum to see if that works --> didn't work
Checked several sources related to this error --> didn't help either
I saw some approaches to get rid of this, since this seems to be a common issue, but I got lost. Someone mentioned an environment variable, which I couldn't put my hands on. Another one suggested to run the JSON request manually, which I tried, but leading to the same error.
Hopefully you can help me out here.
Assuming you AWS lambda, it might be because you didn't create your response right or your AWS lambda function had a error.

Issue with Product.search API call

I'm using Big Cartel's Dugway development environment, and trying to build a live search with Product.search (available with their JS API). It appears to return a set of 20 products no matter what search term, or limit I place on the call, and I'm wondering if anybody else has experienced this? Is it just an issue with the Dugway environment?
More specifically, this is the call I'm making:
Product.search('mugs', { limit: 5 }, function(data) {
console.log(data);
});
This is just the way that products.js works with Dugway, I can confirm that the limit works properly in a live Big Cartel shop. For now maybe you just want to create a for loop and stop at 5 results, or only retrieve 5 from the response another way.

Parse.com Query is empty even though I have data on the server

I'm newbie using parse.com I watched a video tutorial very useful, and now I'm doing my first app. But apparently I think I'm doing something wrong:
I have a Class called MyClass that includes a use. I added a row. In my javascript code I try a simple query by objectId but I'm getting empty results:
var MyClass = Parse.Object.extend("MyClass");
var query = new Parse.Query(MyClass);
query.equalTo("objectId","kX6lNWOpPs");
query.include("user");
query.find({
success: function(results){
console.log("query ok!");
console.log(results);
},
error: function(error){
console.log(error);
}
});
It looks that simple that I'm not sure if I'm doing a huge mistake. The result in the console is:
query ok!
[]
In my class there's a row for sure. I've refreshed the site, even logged out in parse.com. Also the ID is correct, verified a lot of times.
The funny part is that in the video tutorial we used the exact same code, with different classes and data, but same structure.
Thanks in advance for any help. :)
EDIT: if I remove the equalTo and the include functions the results are the same.
EDIT 2: My error was different. I'm ashamed about it :S I had a typo in the Class name: I was using PlayerKey instead of PlayerKeys. The full name doesn't fit on the sidebar column. One of those stupid errors that make you crazy. Besides Parse didn't told me that the class doesn't exists or create it on the query, that only happens as far as I know when you extend. As I said, I'm so newbie :)
If you have the object id then you don't need to run a query as such, you can just get the object with the query:
query.get("kX6lNWOpPs", {
success: function(obj) {
console.log("query ok!");
console.log(obj.id);
},
error: function(object, error) {
console.log(error);
}
});
Note that to use include the user column should be of Pointer type.

Can I relabel the person.noun for Profile object type in Facebook Open Graph?

I have created a Story using Open Graph and the object I want to use is called Service, which is really just a Profile but I want the text in the post to say 'service' rather than 'person' (which it does now). I have tried creating a custom object but it seems overly complicated for what I need so I have 2 questions:
Can I create a custom type that simply inherits from Profile that can be created in the same way (using the FB.api javascript method)? I don't want to have to use self-hosted types..
Can I simply re-label person.noun from 'person' to 'service' somehow? I can't see a way to do that..
My code to post the story is:
FB.login(function (response) {
if (response.authResponse) {
var strmessage = 'Some message';
var profileid = 'xxxxxxxxx;
var opts = {
profile: profileid,
message: strmessage,
no_feed_story: false,
'fb:explicitly_shared': true
};
FB.api('https://graph.facebook.com/me/mynamespace:myaction', 'post', opts, function (response) {
if (!response || response.error) {
Result("Your message has not been posted");
}
else {
//Message has been posted
Result("Your message has been posted");
}
});
You're going to have to do the custom object if you want a custom name. And, you're going to have to do it on the FB Developer site and go through the whole approval process and all that. And no, there is no way to do any sort of inherence on this.
FB's Open Graph is pretty simple if you use the built in actions and objects, but as soon as you go down the road of wanting custom names for stuff, you are going to have to go all in with it.
I finally put the time aside to implement a custom action and type. It wasn't the most intuitive process but I got there in the end and my app is now approved and doing exactly what I wanted it to do. I'm actually glad I put myself through this learning process as custom stories have great potential and I'm sure I'll find other applications for them in the future.

"Cannot call method 'open' of undefined" error when using indexedDB.open

I am new to IndexedDB and I am following this guide IndexedDB Tutorial I am simply trying to create a database and then be able to add a few entries. This is what I have so far.
var db = window.indexedDB.open('FriendDB', 'My Friends!');
if (db.version != '1') {
// User's first visit, initialize database (name, key, auto increment).
db.createObjectStore('Friends', 'id', true);
db.setVersion('1');
} else {
// DB already initialized.
}
var store = db.openObjectStore('Friends');
var user = store.put({name: 'Eric', gender: 'male', likes: 'html5'});
In my console I get the error "Cannot call method 'open' of undefined" how can I get this working? Also if there is a better resource online that would help me because I can't seem to find anything on the topic of IndexedDB for a newbie.
Here is the indexeddb demo from html5rocks which i have improved to work on Mozilla Firefox and added features for viewing details data and editing existing data. Inside you have explanations how to create db, insert, update and delete data in indexeddb.
https://github.com/denimf/IndexedDbToDo
Any time you see code containing a call to setVersion, it's using an outdated syntax. It was unfortunate that we had to make such a big change so late during the spec writing, but it made using IndexedDB correctly tremendously simpler so we decided it was worth it.
There is good documentation on developer.mozilla.org, even though it could definitely be improved.

Categories