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'});
} }

[Angular] Fetch non-JSON data by specifying HttpClient responseType in Angular的更多相关文章

  1. 使用 angular directive 和 json 数据 D3 随着标签 donut chart演示样本

    使用angular resource载入中priorityData.json中间json数据,结合D3绘制甜甜圈图.执行index.html其结果见于图.: priorityData.json中jso ...

  2. fetch发送Form Data请求并携带cookie

    今天我们来说说如何fetch发送Form Data请求并携带cookie,直接进入正题好吧,别问我今天为啥不在开始吹两句了,累到一句牛逼不想吹...... 步骤1: 设置头部,"Conten ...

  3. fetch获取json的正确姿势

    fetch要求参数传递,遇到请求无法正常获取数据,网上其他很多版本类似这样: fetch(url ,{ method: 'POST', headers:{ 'Accept': 'application ...

  4. react之fetch请求json数据

    Fetch下载 npm install whatwg-fetch -S Fetch请求json数据 json文件要放在public内部才能被检索到

  5. [Svelte 3] Use an onMount lifecycle method to fetch and render data in Svelte 3

    Every Svelte component has a lifecycle that starts when it is created, and ends when it is destroyed ...

  6. directly receive json data from javascript in mvc

    if you send json data to mvc,how can you receive them and parse them more simply? you can do it like ...

  7. Google Volley: How to send a POST request with Json data?

    sonObjectRequest actuallyaccepts JSONObject as body. From http://arnab.ch/blog/2013/08/asynchronous- ...

  8. Guzzle Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON

    项目更新到正式平台时,出现Guzzle(5.3) client get请求出现:Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, ...

  9. SQL to JSON Data Modeling with Hackolade

    Review: SQL to JSON data modeling First, let’s review, the main way to represent relations in a rela ...

随机推荐

  1. thrift 版本不一致导致 @Override 报错

    thrift 版本不一致导致 @Override 报错 学习了:http://blog.csdn.net/antony1776/article/details/78920888 版本不一致导致的: 在 ...

  2. Linux中在主机上实现对备机上文件夹及文件的操作的C代码实现

    需求描写叙述 编敲代码.完毕在主机上实现对备机上文件夹及文件的操作. 比如,主机为A,备机为B,要求编写的程序运行在A机上,该程序实如今B机上创建文件文件夹及复制文件的操作. 需求分析 我们先不考虑用 ...

  3. Android学习之——优化篇(1)

    一.优化的品质 1.简练.2.可读性强.3.模块化:4.层次性:5.设计良好.6.高效.7.优雅:8.清晰. 二.常见的编程规范     1. 基本要求 · 结构清晰,简单易懂.单个函数不超过100行 ...

  4. Android获取系统时间的多种方法

    Android中获取系统时间有多种方法,可分为Java中Calendar类获取,java.util.date类实现,还有android中Time实现. 现总结如下: 方法一: ? 1 2 3 4 5 ...

  5. Swift-UITextField用法

    文本框的创建,如下几种方式: UITextBorderStyle.None:无边框 UITextBorderStyle.Line:直线边框 UITextBorderStyle.RoundedRect: ...

  6. 【HDU 5015】233 Matrix

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5015 [算法] 矩阵乘法 [代码] #include<bits/stdc++.h> u ...

  7. Java中Array、List、Set、Map

    一.Java中数组 数组用来存放固定数量的同类元素,声明方法: T[] ref,T ref[],如int[] intAry; int intAry[].推荐用T[]的方式,后一种方式为兼容C++习惯写 ...

  8. [JavaEE] Maven简介

    转载自:百度 http://baike.baidu.com/view/336103.htm?fr=aladdin 一.简介 Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构 ...

  9. Excel里的多列求和(相邻或相隔皆适用)

    最近,需要这个知识点,看到网上各种繁多复杂的资料,自己梳理个思路. 不多说,直接上干货! 简述:将L列.M列和N列,相加放到O列.(当然这里是相邻的列).同时,也可以求相隔几列的某些列相加.

  10. android 打包工具

    sdk.jar-修改路径-JarToDex-DexToSmali-复制文件