0

I am receiving strange characters from the json file, so i guess the problem with the encoding so i need to add header to my http get request in the service i think something like this

headers.append('Content-type' , 'application/json;charset=UTF-8');

and here is my source service code:

import { Component, Input } from '@angular/core';
import { Injectable }     from '@angular/core';
import { Http, Response, Headers, RequestOptions } from 
'@angular/http';
import { HttpClient } from '@angular/common/http';
import {Observable} from 'rxjs/Rx';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';

@Injectable()
export class listsService{

 constructor(private http: HttpClient) {   }
   //get data from json file
  getList(){
   return this.http.get('../data.json')
  .catch(err => {return "no data";});
 }

}

Mo Halem
  • 184
  • 2
  • 12
  • 1
    https://stackoverflow.com/questions/45286764/angular-httpclient-doesnt-send-header – Vino Thini Nov 22 '18 at 10:47
  • 4
    Possible duplicate of [Angular HttpClient doesn't send header](https://stackoverflow.com/questions/45286764/angular-httpclient-doesnt-send-header) – David Nov 22 '18 at 10:58

0 Answers0