By default the new Angular Http client (introduced in v4.3.1) uses JSON as the data format for communicating with the backend API. However, there might be situations where you may want to use some other format, like text/plain for fetching a CSV file. Using the responseType property this can be achieved quite easily.

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http'; @Injectable()
export class PeopleService { constructor(private http: HttpClient) {} fetchPeople(): Observable<Object> {
return this.http
.get('data/people.txt', { responseType: 'text'});
} }

最新文章

  1. Atitit java c# php c++ js跨语言调用matlab实现边缘检测等功能attilax总结
  2. 从梯度下降到Fista
  3. 进程间通信--pipe
  4. Quartz应用实践入门案例二(基于java工程)
  5. JSON格式互转集合
  6. nginx的主要用途
  7. poi 导出 excel
  8. 在linux上安装psycopg2出错--Error: pg_config executable not found.
  9. 移动端 移动web屏幕适配方案 随不同宽度的屏幕而改变
  10. MEF 编程指南(五):延迟导出
  11. Javascript 知识点简介
  12. IOS开发-UI学习-根据URL显示图片,下载图片的练习(button,textfield,image view,url,data)
  13. C# WinForm调用UnityWebPlayer Control控件 &lt;学习笔记1&gt;
  14. POJ 3182 The Grove [DP(spfa) 射线法]
  15. AI繁荣下的隐忧——Google Tensorflow安全风险剖析
  16. Python爬虫入门教程 15-100 石家庄政民互动数据爬取
  17. loj#6074. 「2017 山东一轮集训 Day6」子序列(矩阵乘法 dp)
  18. Python系列:四、Python函数--技术流ken
  19. TableView刷新跳动问题
  20. Spring.之.jar包官网下载

热门文章

  1. 基于Solr的HBase实时查询方案
  2. Unity里包裹Debug,且不影响Debug的重定向
  3. USACO 2.1 Ordered Fractions
  4. C++中的pair,make_pair学习
  5. 视图 Model转集合
  6. layui序章
  7. vue-cli搭建项目结构及引用bootstrap
  8. C语言整数类型在X86和X64下的字节大小
  9. Core Graphics框架 利用Quartz 2D绘图
  10. day15 函数对象以及作用域