Skip to content

Http Requests and Http Injectables #3086

@tbragaf

Description

@tbragaf

Hi all !

I think httpInjectables are not working completely...


Problem 1

This is my Service:

@Component({
    viewInjector: [httpInjectables]
})
export class Service {
   constructor(http : Http) {
        ObservableWrapper.subscribe(http.get('http://api.github.com/users'), res => { 
            debugger
            this.people = res.json()
        });
   }
}

Which throws this:
image

This is my bootstrap:

bootstrap(Application, []);

But only if I change my bootstrap, I can run the code..

bootstrap(Application, [httpInjectables]);

Any ideas why is this happening?
I mean, if I want my service component to be distributed to other applications, I need to add httpInjectables to bootstrap? Seems wrong... The idea of NG2 was to build scalable and independent components.


Problem 2

If I request a non existing resource (it also happens locally):
image

The status body id correct, but the status code is not and always returns 200.

Best regards,
Tiago Braga

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions