Skip to content

Commit 71808f2

Browse files
Merge pull request #818 from NullVoxPopuli/remote-data-text
Support text conversion with RemoteData
2 parents 21e217d + feeb2db commit 71808f2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/young-taxis-stare.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ember-resources": minor
3+
---
4+
5+
RemoteData now checks the response's Content-Type header to decide whether to convert to JSON or Text

ember-resources/src/util/remote-data.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ export function remoteData<T = unknown>(
125125
.then((response) => {
126126
state.status = response.status;
127127

128-
return response.json();
128+
if (response.headers.get('Content-Type')?.includes('json')) {
129+
return response.json();
130+
}
131+
132+
return response.text();
129133
})
130134
.then((data) => {
131135
state.isResolved = true;

0 commit comments

Comments
 (0)