No provider for Http! error in ionic


#22

Thank Josh, you saved me a ton of time and frustration! :slight_smile:

Next drink is on me :wink:


#23

thank you very much! saved my life :slight_smile:


#24

TY for all your Ionic help… The world is better with this :sunny:


#25

Thanks alot Yahoooooo <3


#26

Thank you @joshnash :slight_smile:


#27

@joshmorony for president :raised_hand_with_fingers_splayed:t5::grimacing:


#28

Worked!!!

Thank you Josh!


#29

Great men, thanks, it worked for me


#30

Exactly what i need to fix my issue. Million thanks.


#31

It works perfectly, thank you


#32

To me I get the following error I already made all imports of both the http and the HttpModule but console tells me the following I could do in that case.
Help me please.
XMLHttpRequest cannot load https://stackoverflow.com/questions/44666191/angular-4-angular-cli-error-no-provider-for-object-object No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access.


#33

Thanks You @joshmorony you saved my evening :slight_smile:


#34

I used
import {HttpModule} from '@angular/Http’
and it didn’t work.
But when I used
import {HttpModule} from '@angular/http’
it worked.
It seems the imports are CASE-SENSITIVE.


#35

Depends on your filesystem.


#36

Helped me too. Thanks Josh


#37

hi…

Is the procedure for importing/Defining services or modules like http and all in app.module.ts in both “ionic2” and “ionic3” same?? …
I am doing a project in ionic 3 for that I am referring ionic 2 project videos .
please help me


#38

thank you dude, save my time.


#39

in home.ts file i’ve this list of params

var params = {
                  service: this.toBase64('register'),
                  device_id: this.toBase64(this.device.uuid),
                  org_name: this.toBase64(this.orgName),
                  org_email: this.toBase64(this.orgMail),
                  org_address: this.toBase64(this.orgAddress),
                  org_boardnumber: this.toBase64(this.boardNumber),
                  org_password: this.toBase64(this.password),
                  org_phone: this.toBase64(this.orgPhone)
        }

             this.regProvider.postRequest(params)
           .subscribe(response => console.log(response))

there is method postRequest() in Provider there is file register.ts. Here is method implementation.

postRequest(params) {
        var headers = new Headers();
        headers.append("Accept", 'application/json');
        headers.append('Content-Type', 'application/json' );
        headers.append('Access-Control-Allow-Origin', '*' );
     
        let options = new RequestOptions({ headers: headers });
     let jsonData = JSON.stringify(params)
    
    return  this.http.post(this.baseUrl, jsonData, options)
          .map(response => response.json());
      }

when i run application. this error appears

Screen Shot 2017-11-21 at 12.38.59 PM.png

Can anyone help me where i made mistake.Thanks


#40

thank you! !!!


#41

Thanks! Solved the problem. Had to change it from HttpClient to just Http in the constructor.
Cheers!