I discovered that axios is returning a string instead of a valid json.

headers:Object {date: "Tue, 02 Jun 2020 08:44:06 GMT", server: "Apache", connection: "close", …}

connection:"close"

content-type:"text/html; charset=UTF-8"

date:"Tue, 02 Jun 2020 08:44:06 GMT"

server:"Apache"

transfer-encoding:"chunked"

how do I change the content-type to application/json in NestJs application?

I tried this but didnt not work

const meterInfo = await this.httpService.get(url, { headers: { "Content-Type": "application/json" } }).toPromise();

Here is the invalid json returned.

"{"status":"00","message":"OK","access_token":"2347682423567","customer":{"name":"John Doe","address":"Mr. John Doe 34 Tokai, leaflet. 7999.","util":"Demo Utility","minimumAmount":"13897"},"response_hash":"c43c9d74480f340f55156f6r5c56487v8w"}"

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐