尝试使用Angular 4(http:HttpClient)和Google API(云端硬盘)从Google云端硬盘(Docs)获取文档内容正文。
this.http.get('https://www.googleapis.com/drive/v3/files/fileIDDDDDDDDDDDDDDDDDDDDDDDDDDDDD/export', {
observe: 'response',
params: new HttpParams()
.set('key', 'KEYYYYYYYYYYYYYYYYYYYYYYYYY')
.set('mimeType', 'text/plain'),
})
.subscribe(resp => {
this.data = resp;
console.log(resp);
});
Ausgabe:
{…}body: null
headers: Object { normalizedNames: Map, lazyUpdate: null, lazyInit: HttpHeaders/this.lazyInit() }ok: truestatus: 200statusText: "OK"type: 4url: "https://www.googleapis.com/drive/v3/files/filIDDDDDDDDDDDDDDDDDDD/export?key=keyyyyyyyyyyyyyyyyyyyyyyyyyyyy&mimeType=text/plain"__proto__: Object { constructor: HttpResponse(), clone: ../../../common/@angular/common/http.es5.js/HttpResponse.prototype.clone() } rechtespalte.component.ts:64:16
正如您所见,请求可以,但是身体保持空白。
仅请求https://www.googleapis.com/drive/v3/files/fileIDDDDDDDDDDDDDDDDDDDDDDDDDDDDD个响应文件名以及其他一些数据。
我如何获得GoogleDoc的内容?