# Ionic 3: Header is not assigned value

**URL:** <https://forum.ionicframework.com/t/ionic-3-header-is-not-assigned-value/130576>\
**Category:** ionic-v3\
**Created:** [May 15, 2018, 5:24pm UTC](https://forum.ionicframework.com/t/ionic-3-header-is-not-assigned-value/130576 "2018-05-15T17:24:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajbasilio](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rajbasilio](https://forum.ionicframework.com/u/rajbasilio)\
**Post date:** [May 15, 2018, 5:24pm UTC](https://forum.ionicframework.com/t/ionic-3-header-is-not-assigned-value/130576/1 "2018-05-15T17:24:39Z")

</div>

this is my code

```auto
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';

import 'rxjs/add/operator/map';
import { Headers } from '@angular/http';

@Injectable()
export class DataproviderProvider {

  constructor(public http: HttpClient) {
    console.log('Hello DataproviderProvider Provider');
  }

  // registering the user
  resgisterData(registerdata) {
    let headers = new Headers({'Content-Type': 'application/json'});
    this.http.post('http://localhost:3000/api/contact',registerdata,{headers: headers})
    .map(res => res.json());

  }
}

```

I’m getting error like

> Argument of type ‘{ headers: Headers; }’ is not assignable to parameter of type ‘{ headers?: HttpHeaders | { [header: string]: string | string; }; observe?: “body”; params?: Ht…’. Types of property ‘headers’ are incompatible. Type ‘Headers’ is not assignable to type ‘HttpHeaders | { [header: string]: string | string; }’. Type ‘Headers’ is not assignable to type ‘{ [header: string]: string | string; }’. Index signature is missing in type ‘Headers’.

In visual studio code, it is displaying error at {headers: headers}

---

<div class="post-metadata">

**Author:** ![zyzmoz](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zyzmoz/32/111584_2.png) [@zyzmoz](https://forum.ionicframework.com/u/zyzmoz)\
**Post date:** [May 15, 2018, 5:27pm UTC](https://forum.ionicframework.com/t/ionic-3-header-is-not-assigned-value/130576/2 "2018-05-15T17:27:27Z")

</div>

Use HttpHeaders instead Headers;

```auto
let headers = new **HttpHeaders** ({'Content-Type': 'application/json'});

```

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [May 15, 2018, 8:34pm UTC](https://forum.ionicframework.com/t/ionic-3-header-is-not-assigned-value/130576/3 "2018-05-15T20:34:00Z")

</div>

Don’t bother with headers at all. What you _do_ want to do is define a business model interface and use it:

```auto
interface RegistrationRequest {
 // stuff goes here
}

interface RegistrationResponse {
  // other stuff goes here
}

registerUser(regfood: RegistrationRequest): Observable<RegistrationResponse> {
  return this.http.post<RegistrationResponse>(api, regfood);
}

```

Always type all method arguments and return values. It makes your code self-documenting and easier to read, and helps the build tools and your development environment help you avoid silly bugs.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:35pm UTC](https://forum.ionicframework.com/t/ionic-3-header-is-not-assigned-value/130576/4 "2021-07-19T21:35:29Z")

</div>


