gizm0bill / angular2-rest-client Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
This is a feature request.
I'm wondering if it's possible to do something like:
@Injectable()
@BaseUrl('http://localhost:8080/rest/service')
export class ManagerService extends AbstractApiClient {
constructor(protected http: Http) { super(http); }
@Type(ResponseContentType.Json)
@GET('/batch')
public batches( ): Observable<TypedResponse<Batch[]> { return; }
}
I would assume that TypedResponse would extend the current response.
With current solution all I need to do is cast the json response to that Batch[]...
const response: Observable<Response> = this.service.batches();
response.subscribe(item => {
const b = item.json() as Batch[];
console.log(b[0].startTime);
});
It would just be a lot more convenient if this was done inside. Not sure if this is possible of course.
I'm a serious newby with js and ts and have tried to have a look at where this could be put but have no clue where to start...
Hello,
I have this really simple code
@BaseUrl('http://127.0.0.1:8000/api/v1')
@Injectable()
export class TestService extends AbstractApiClient {
constructor( protected http: Http ) { super(http); }
@Type( ResponseContentType.Json )
@GET('/test') public readTest(): Observable<Response> { return }
}
But the request goes like this:
OPTIONS /api/v1/test HTTP/1.1
Host: 127.0.0.1:8000
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://localhost:4200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Access-Control-Request-Headers: content-type
Accept: */*
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: es-419,es;q=0.8,en;q=0.6,lt;q=0.4
I know that this is CORS, is there a way to just go straight to the actual request?
Description:
Getting error when running application (with "angular2-rest-client" dependency)
Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/traceur
Error loading http://localhost:3000/node_modules/angular2-rest-client/index.js as "angular2-rest-client" from http://localhost:3000/app/app.service.js
Steps To Reproduce:
npm install angular2-rest-client
Error loading http://localhost:3000/node_modules/angular2-rest-client/index.js as "angular2-rest-client"
Comment:
It looks like the content of index.js
isn't a valid javascript.
Maybe it's not transpiled to JS?
index.js
of the v1.0.9 is:
export * from './src/angular2-rest-client';
//# sourceMappingURL=index.js.map
Are you still supporting this and plan to support the latest Angular 4.
I may be able to contribute. I like the pattern you are using.
let subject: ReplaySubject<string>;
let source = this.http.get(url).map( (r: Response) => r.json()[key] );
if ( !baseUrlCache )
{
baseUrlCache = new Observable( observer =>
{
if ( !subject )
{
subject = new ReplaySubject(1);
source.subscribe( (value) => subject.next(value), err => { let s = subject; subject = null; s.error(err); }, () => subject.complete() );
}
subject.subscribe(observer);
});
}
return baseUrlCache;
Hi There!
Is there a way to add a set of Query parameters that can go with all requests in the ApiClient class. Just like the way we have global Headers.
For example: I need to send timezone parameter to our server for all the requests that we are making. Instead of adding it to all my request methods I would love to have it added as a global.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.