Http Request in ionic with Headers


#1

This is my code

import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;

import { Http, Response,Headers,RequestOptions} from ‘@angular/http’;
import ‘rxjs/add/operator/map’;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {

constructor(public navCtrl: NavController, public http:Http) {
var headers=new Headers();
headers.append(‘Accept’,‘application/json’);
headers.append(‘Authorization’,‘Basic c2FuY2hpdGFAaXNpc2Rzbi5uZXQ6MTIz’);

  this.http.get('http://ec2-54-68-124-204.us-west-2.compute.amazonaws.com/Dersluth/api/users/test.json',{"headers": headers}).subscribe(data=>{
	 console.log(data);
  });

}

}

please help me as much as possible .

Headers is not added at request time


#2

Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.