Yelp API key not working in Sencha Architect demo code - extjs

I am using the tutorial here : http://docs.sencha.com/architect/3/tutorials/first_mobile_application.html#The_Controller
getBusinesses: function(location, callback) {
// Note: Obtain a Yelp API key by registering (for free)
// with Yelp at http://www.yelp.com/developers/getting_started/api_overview
// (in this app, we use the Review Search API v1.0)
var store = Ext.data.StoreManager.lookup('BusinessStore'),
yelpKey = '', // Enter your Yelp API key here
url = 'http://api.yelp.com/business_review_search' +
'?ywsid=' + yelpKey +
'&term=Bars' +
'&lat=' + location.coords.latitude +
'&long=' + location.coords.longitude;
store.getProxy().setUrl(url);
store.load(function() {
callback(store);
});
}
I applied for an API key on Yelp and got the following:
I am not sure which one to use. The tutorial code has placeholder for one single key as in the code above
The completed app shows error: Uncaught TypeError: Cannot read property 'setStore' of undefined at:
me.getBusinesses(location, function (store) {
// Bind data to the list and display it
me.getDataList().setStore(store);

You need the API v1.0 key.
getDataList() returns undefined because the View does not exist. You may have forgotten to name the List view in the ListContainer, see "List View - Step 4". Also, the function name is derived from whatever you set the reference to in *"The Controller - Step 7". Naming it datalist will make the function getDatalist(), whereas naming it dataList will make it getDataList(). Note the capital "L".
Hope this helps others running into the problem.

Related

Uncaught (in promise) TypeError: viewer.loadExtensionAsync is not a function

checkout the code on this link
https://codepen.io/vibhav-joshi/pen/KKejEvE?editors=0010
We are trying to get the heatmap on our revit model but we are unable to show the heatmap. Tried several ways like changing the extensions from getExtensions() to loadExtensions() still nothing is showing in the viewer.
There's no method called loadExtensionAsync in the viewer API. You can use the loadExtension method which is also asynchronous (so you can await it), or getExtension if the extension was already loaded before.
Also, please note that we have recently updated our DataViz demo, https://aps-iot-extensions-demo.autodesk.io, and you can find its source code here: https://github.com/autodesk-platform-services/aps-iot-extensions-demo.
According to the Viewer Documentation, viewer.loadExtensionAsync() does not exist. You must use viewer.loadExtension(extensionId).
As the return type is a promise, this function is async so you should await the result like that :
const dataVizExt = await viewer.loadExtension("Autodesk.DataVisualization");
Another way of doing this, is adding the "Autodesk.DataVisualization" extension in the options of the Viewer when creating the Viewer instance :
const config = {
extensions : [
"Autodesk.DataVisualization"
]
};
let viewer = new Autodesk.Viewing.Viewer3D(document.getElementById('forgeviewer'), config);
Then you should be able to get the extension like that :
const dataVizExt = await viewer.getExtensionAsync("Autodesk.DataVisualization");
or
var dataVizExt;
viewer.getExtension("Autodesk.DataVisualization", (ext)=>{
dataVizExt = ext;
});

TypeError: ref.key is not a function

AngularJS: v1.5.11
Firebase: v3.6.9
Angularfire: v2.3.0
I want to get the key. After creating the JSON object my code :
}).then(function(ref){
var id = ref.key();
console.log("Added User with ID: "+id);
The value is inserted in the firebase DB but getting this error and nothing is shown in the console log.
I guess the syntax to get the key is changed with these versions. I don't know what the ref.key() is used for really. Is it required as to set some primary key?
Reference.key() used to be a function in Firebase JavaScript SDK 2.x. But is is now a read-only property, so you should use ref.key.
This and many more things to be aware of when upgrading your code are covered in the Firebase migration guide for web developers: https://firebase.google.com/support/guides/firebase-web
}).then(function(ref){
var id = ref.key();// remove this
var id = ref.key; // use this
console.log("Added User with ID: "+id);
var id=ref.key()
In this line of code you need to use "ref.key" instead of "ref.key()"

How to add to a list in Firebase without overwriting

I am trying to create a 'Favorites' section in my app where you hit a button and it is added to a user favorites list in firebase. I am using the ionic platform.
I created a factory to handle the favourites as they come in. and i use the getAuth() function to get the unique userID so i can just pull it when the user logs on. This is my attempt but i am not getting the result i wanted which is simply something like :
< userid >:
{
0: "fav1"
1: "fav2"
}
.factory('Favourites',function($firebaseArray){
var ref = new Firebase("https://experiencett.firebaseio.com/");
var authData = ref.getAuth();
var favs = $firebaseArray(new Firebase('https://experiencett.firebaseio.com/favourites/'+authData.uid+''));
return {
all: function() {
return favs;
},
add: function(){
var up=new Firebase('https://experiencett.firebaseio.com/favourites/');
var usersref=up.child(authData.uid);
usersref.push({3:"paria"});
},
When you call push() you are generating a unique id. While that is great for many use-cases, it is not good here since you want to control the path that is written.
Since you're already constructing the path with child(authData.uid) you can simply update it with update():
usersref.child(authData.uid).update({3: "paria"});
This will either update the existing value at 3 or write the new value for 3, leaving all other keys under /users/<uid> unmodified.
Alternatively if you want to replace the data that already exists at users/<users>, you can use set() instead of update().
This is all covered in the Firebase JavaScript SDK in the section on storing user data. It is not covered in the AngularFire documentation, since there is nothing specific to Angular about it.

Linking Data in Firebase

I am designing a forum and have a layout like this in on my Firebase:
root
|-posts
|-postID1
|-creator: "userOne"
|-creatorUID: "simplelogin:1"
|-text: "Some Text"
|-postID2
|-creator: "userTwo"
|-creatorUID: "simplelogin:2"
|-text: "Some Other Text"
|-profile
|-simplelogin:1
|-firstName: "John"
|-user: "userOne"
|-simplelogin:2
|-firstName: "Sue"
|-user: "userTwo"
On my forum page. I simply use a Angular ng-repeat to get all of the posts on Firebase and list them out. I also want to print out the first name of whoever created the post, but right now, I can only access {{ post.creator }}, which just gives the username of the person who posted. How can I link the post's creator (or creatorUID) with the first name field of that person's profile?
If you're just displaying the the users firstName I would place the users name in the postIDX object.
This would be quicker and produce less requests to Firebase with you going back and fourth with each post to get the usersFirst name.
more information on structuring data and best practices can be found here: https://www.firebase.com/docs/web/guide/structuring-data.html
Updated from response
if you wanted to get the user details then within every request to the postIDx you'd need to do something similar to this (not tested and quick mock up).
var fbRef = new Firebase('firebase path'),
postDetailsObject = {};
fbRef.child('posts').once('value', function(snapshot) {
// loop through each post
snapshot.forEach(function(childSnapshot){
var postDetails = childSnapshot.val(),
profileDetails;
postDetailsObject.post = postDetails;
fbRef.child('profile/' + postDetails.creatorUID).once('value', function(profileData) {
postDetailsObject.profile = profileData;
});
})
});
Then return the postDetailsObject in to angular so you can loop through the single object.

drive realtime api model toJson not populating fields in custom type

I'm building a Drive Realtime project using custom types: https://developers.google.com/google-apps/realtime/custom-objects.
I'm having an issue where the fields in my custom objects are not exported in the model.toJson() output. I'm sure I'm just missing something, but I haven't been able to find any differences with how I'm constructing the custom object vs. the realtime playground or the realtime API documentation.
Sample repro case using the realtime playground is below.
1) go to realtime playground: https://realtimeplayground.appspot.com/
2) open developer console
3) Run the following code
test = function () {}
test.prototype = { init: function() { this.name = 'testName';}};
test.prototype.name = gapi.drive.realtime.custom.collaborativeField('name');
gapi.drive.realtime.custom.registerType(test, 'testType')
gapi.drive.realtime.custom.setInitializer(test, test.prototype.init);
var model = window.doc.getModel()
model.getRoot().set('myTest', model.create(test));
model.toJson()
observed output:
"{"id":"root","type":"Map","value":
{"demo_string":
{"id":"Tq50c9iybcXi","type":"EditableString","value":"Edit Me!"},
"demo_list":{"id":"ZmjclOeUbcXj","type":"List","value":
[{"json":"Cat"},{"json":"Dog"},{"json":"Sheep"},{"json":"Chicken"}]},
"demo_cursors":{"id":"6TJ6Zzd2bcXj","type":"Map","value":{}},
"demo_map":{"id":"ukRRMPHbbcXj","type":"Map","value":
{"key1":{"json":"value 1"},"key2":{"json":"value 2"},"key3":{"json":"value 3"}}},
"demo_custom":{"id":"44nsuMAPbcXk","type":"DemoMovie","value":
{"name":{"json":"Minority Report"},
"director":{"json":"Steven Spielberg"},
"notes":{"json":""},"rating":{"json":""}}},
"myTest":{"id":"Kq4hcV4UbcvW","type":"testType","value":{}}}}"
Expected:
"{"id":"root","type":"Map","value":
{"demo_string":
{"id":"Tq50c9iybcXi","type":"EditableString","value":"Edit Me!"},
"demo_list":{"id":"ZmjclOeUbcXj","type":"List","value":
[{"json":"Cat"},{"json":"Dog"},{"json":"Sheep"},{"json":"Chicken"}]},
"demo_cursors":{"id":"6TJ6Zzd2bcXj","type":"Map","value":{}},
"demo_map":{"id":"ukRRMPHbbcXj","type":"Map","value":
{"key1":{"json":"value 1"},"key2":{"json":"value 2"},"key3":{"json":"value 3"}}},
"demo_custom":{"id":"44nsuMAPbcXk","type":"DemoMovie","value":
{"name":{"json":"Minority Report"},
"director":{"json":"Steven Spielberg"},
"notes":{"json":""},"rating":{"json":""}}},
"myTest":{"id":"Kq4hcV4UbcvW","type":"testType","value":{"json":"testName"}}}}}"
Registering custom types can only occur during the "Pre-Load" phase of the document life cycle. Your code is correct, but is being executed on the document after the document has loaded. This causes the custom object to not be properly constructed, which is why it is lacking the JSON value that you have specified in the init function.
To see the correct flow in action, put a break point on line 88 of static/elements/playground-app.js in the Realtime Playground application. Refresh the page and when execution has paused, run this code from the console:
test = function () {}
test.prototype = { init: function() { this.name = 'testName';}};
test.prototype.name = gapi.drive.realtime.custom.collaborativeField('name');
gapi.drive.realtime.custom.registerType(test, 'testType')
gapi.drive.realtime.custom.setInitializer(test, test.prototype.init);
Resume execution. When the application has fully loaded, run the rest of your code:
var model = window.doc.getModel()
model.getRoot().set('myTest', model.create(test));
model.toJson()
You will see that the outputted JSON matches what you are expecting:
"myTest":{"id":"1OiQd2QoEqBs","type":"testType","value":{"name":{"json":"testName"}}}
This workflow is documented under the "Registering custom types and fields" title of the Custom Collaborative Objects guide.

Resources