These are chat archives for jgamedev/nativescript

10th
Oct 2017
WebbKD
@WebbKD
Oct 10 2017 13:35
hey guys im looking for some help with native script
I am trying to use the yelp api within angular and type script but have no idea where to start to figure out to do it. Never used an api before. Would like some tips
to where to find this
Chrizzly
@Chris2011
Oct 10 2017 13:41
I think this is not really related to native script
first you should install the yelp package via npm
than you need to find the type definition, if you have luck, it should be @types/yelp or smth like that. Google for it.
Than you need to import that dependency to your TS file like any other module.
And then you should be able to use it.
So this is more a TS question, than NativeScript.
This is usual work with modules in TS
Ok I thought it is a NPM module but it is a REST API, right?
So then you can use the http request api in Angular.
Then this is more an angular question :)
So not that hard to search and find it via google first.
@WebbKD
WebbKD
@WebbKD
Oct 10 2017 13:46
I looked at it via google search I had that tab open, the sytax is just different since I never used/seen something like this before
Chrizzly
@Chris2011
Oct 10 2017 13:46
Share the link
I don't know what you mean, which syntax?
WebbKD
@WebbKD
Oct 10 2017 13:48
within the same stackoverflow link you shared
var express = require('express');
is this guy using express js?
Chrizzly
@Chris2011
Oct 10 2017 13:49
yes
and oauth-request smth like that
He is using this, for his own proxy/rest api
as you can see he has an endpoint called: /getdealsforlocation
and inside of this, he does some magic with the yelp api
so he is using node with TS
here is the documentation for require() in node.
Module loader, if you didn't know that. So example is not an angular + TS example, it is purely node with express
using node as the backend REST API Server
Don't be confused, the stuff inside the get method is more interesting for you. Do a normal http request in angular to the yelp API like to any other REST API
and subscribe to it via RxJS
So no npm package needed (maybe the oauth think to send the credentials) and no module requirement.
WebbKD
@WebbKD
Oct 10 2017 13:54
this is helpful
imma give it a go
Chrizzly
@Chris2011
Oct 10 2017 13:55
have fun and gl :)
WebbKD
@WebbKD
Oct 10 2017 13:56
@Chris2011
// Simple GET request example:
$http({
method: 'GET',
url: '/someUrl'
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
so I will be following this pretty much?
Chrizzly
@Chris2011
Oct 10 2017 13:57
where did you get it? Looks like angularjs and not angular.
But more or less
Chrizzly
@Chris2011
Oct 10 2017 13:57
This is angularJS 1
not 2
WebbKD
@WebbKD
Oct 10 2017 13:57
oh wow I was looking up the wrong things this whole time
Chrizzly
@Chris2011
Oct 10 2017 13:58
I think Angular (2) doesn't have any $ before any, in JS. Only ${myVar} is ES2015 template strings
So as a hint, if you see $smth it could be jQuery or AngularJS 1
WebbKD
@WebbKD
Oct 10 2017 13:59
good to note for next time
Chrizzly
@Chris2011
Oct 10 2017 13:59
But the link that I send you, is the Angular2 documentation
WebbKD
@WebbKD
Oct 10 2017 14:00
Sweet, I am new to angular2 and these frameworks in general
Chrizzly
@Chris2011
Oct 10 2017 14:01
Angular is not called Angular2 anymore, because it has sem version
We are now at Angular5 or so
So AngularJS is ver.1 (more or less) and Angular is the newest version, which should be 5
WebbKD
@WebbKD
Oct 10 2017 14:01
thank you for clearing this up
Here we have a slack community for Angular in general (1, 2, ionic, TypeScript): https://angularjs-de.slack.com/
in general it is german, but you can ask in english if you want too, so there is no problem.
WebbKD
@WebbKD
Oct 10 2017 21:55
@Chris2011 yeah man I am still lost with this