Code Monkey home page Code Monkey logo

angular2-rest-client's People

Contributors

dependabot[bot] avatar discountrobot avatar gizm0bill avatar mmrath avatar nilpferdschaefer avatar paldom avatar tn-kirontech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

angular2-rest-client's Issues

Extend interface to include the type of the response

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...

Question: Requests OPTIONS instead of GET (Prevent CORS)

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?

SystemJS XHR error while running application

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:

  1. npm install angular2-rest-client
  2. add it to dependencies
  3. Seen an error 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

Still supported and Angular4

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.

Fix BaseURl cache.. or wait for rxjs

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;

How to specify global query parameters?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.