An Angular 2 Webpack Starter kit featuring Angular 2, Router, TypeScript, and Webpack by AngularClass
the error you get has something to do with cors. i never used uber api before, try to search on the web http://stackoverflow.com/questions/8685678/cors-how-do-preflight-an-httprequest
for ng2 authentication try https://www.npmjs.com/package/angular2-jwt also if you are not in a hurry read https://medium.com/@blacksonic86/authentication-in-angular-2-958052c64492#.69wcuux91
this is for frontend, you also need to implement the backend counterpart
This error in Mozila :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.uber.com/v1/products?latitude=12.9716&longtitude=77.5946. (Reason: missing token 'access-control-allow-headers' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel).
This error is in Chrom:
XMLHttpRequest cannot load https://api.uber.com/v1/products?latitude=12.9716&longtitude=77.5946. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.
i am not sure it origin mismatch or token not assigned in the header, i am not using oauth i just want to authenticate with server token provided by the uber api server.
this is my code:
client.service.ts
getEstimatesForUserLocation (lat:number,lon:number) {
let endpoint = 'https://api.uber.com/v1/products';
let url = `${endpoint}?latitude=${lat}&longtitude=${lon}`;
let headers = new Headers();
headers.append('Authorization', 'SERVER_TOKEN');//assigning my server token to header
headers.set('Access-Control-Allow-Origin', '*');
headers.get('Access-Control-Allow-Origin');
headers.append('Access-Control-Allow-Headers','x-requested-with, Content-Type, origin, authorization, accept, client-security-token');
headers.get('Access-Control-Allow-Headers');
return this.http.get(url, {headers})
.map(res => res.json());
}
client.component.ts
getEstimatesForUserLocation() {
this._countryService.getEstimatesForUserLocation(this.lat, this.long )
.subscribe(
data=> this.row = data,
error =>this.error = "location" + this.lat + this.long + "invalid."
);
}
can any one please tell me server token which i am assigning here is correct?
note: i am using @angular/http package
'//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead.
and a lot of them warnings whenever the application bootstraps90% optimize assetsError in bail mode: [default] /Users/Daily/Shortcut-Webpack/typings/browser/ambient/jquery/index.d.ts:3223:12
Subsequent variable declarations must have the same type. Variable '$' must be of type 'cssSelectorHelper', but here has type 'JQueryStatic'.
and I cannot figure out how I fixed it the first time, does anyone know?
@meiblorn
Hi, guys! I need help.
I am trying to write quick start for system.js for my first open source library: http://plnkr.co/edit/oeOnHTmWasmOgRhbKkcB?p=preview.
It throws "$ is not a function" error.
I am using typings in my project but don't know how to install typings in plnkr.
Help me to fix it, please.
(<any>$)(this._el.nativeElement).fullpage(this.options);
Would just like to tell you that you guys who have made this are amazing. Theres nothing worse than jumping into a stack and going, uh.. but what do I use...
The documentation is great and it looks like it's got everything I want.
Has anyone made an in-depth guide to the entire solution? I would love a video series using this explaining all the components and how they work.
Once again. THank YOU@!!@!
derzunov:angular2-webpack-starter derzunov$ sudo typings install
typings ERR! message Attempted to compile "zone.js" as an external module, but it looks like a global module.
typings ERR! cwd /Users/derzunov/projects/Angular2/angular2-webpack-starter
typings ERR! system Darwin 15.4.0
typings ERR! command "/usr/local/bin/node" "/usr/local/bin/typings" "install"
typings ERR! node -v v4.4.4
typings ERR! typings -v 1.0.2
typings ERR! If you need help, you may report this error at:
typings ERR! https://github.com/typings/typings/issues
Hey guys, I'm having a problem importing ng2-formly stuff into the webpack starter. I think it's because it's using SystemJS to export the modules?
repo: https://github.com/formly-js/ng2-formly
npm install ng2-formly --save results in ng2-formly.js in node_modules/ng2-formly which looks like this:
System.register(["./src/main", "./src/templates"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
function exportStar_1(m) {
var exports = {};
for(var n in m) {
if (n !== "default") exports[n] = m[n];
}
exports_1(exports);
}
return {
setters:[
function (main_1_1) {
exportStar_1(main_1_1);
},
function (templates_1_1) {
exportStar_1(templates_1_1);
}],
execute: function() {
}
}
});
import {FormlyForm} from "ng2-formly/ng2-formly";
@ollwenjones
What I"m currently doing is having an project which is basically a fork of webpack starter, I keep pulling in here the newest update and tweak it to use my own libraries, I then pull that into my other projects which mostly works fine.
Do have to add that I keep having to remove home, about and changes to RouteConfig. But it's trivial.