Skip to content

Commit 39d6fe4

Browse files
Address PR Comments
1 parent 0144638 commit 39d6fe4

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/identityApiClient.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,11 @@ export default function IdentityAPIClient(
130130

131131
// FetchUploader returns the response as a JSON object that we have to await
132132
if (response.json) {
133-
// HTTP responses of 202, 200, and 403 do not have a response.
133+
// HTTP responses of 202, 200, and 403 do not have a response body.
134134
// response.json will always exist on a fetch, but can only be
135135
// await-ed when the response is not empty, otherwise it will
136136
// throw an error.
137-
try {
138-
aliasResponseBody = await response.json();
139-
} catch (e) {
140-
verbose('The request has no response body');
141-
}
137+
aliasResponseBody = await response.json();
142138
} else {
143139
// https://go.mparticle.com/work/SQDSDKS-6568
144140
// XHRUploader returns the response as a string that we need to parse
@@ -149,9 +145,6 @@ export default function IdentityAPIClient(
149145
: '';
150146
}
151147

152-
// https://go.mparticle.com/work/SQDSDKS-6670
153-
message = 'Successfully sent alias request to mParticle Servers';
154-
155148
if (response.status === HTTP_BAD_REQUEST) {
156149
// 400 has an error message, but 403 doesn't
157150
const errorResponse: IAliasErrorResponse = aliasResponseBody as unknown as IAliasErrorResponse;
@@ -165,6 +158,15 @@ export default function IdentityAPIClient(
165158
if (errorResponse?.code) {
166159
message += ' - ' + errorResponse.code;
167160
}
161+
} else {
162+
// https://go.mparticle.com/work/SQDSDKS-6670
163+
message = 'Received Alias Response from server: ';
164+
message += JSON.stringify(response.status);
165+
166+
// In case we receive a valid HTTP code with a response body
167+
if (aliasResponseBody) {
168+
message += ' - ' + JSON.stringify(aliasResponseBody);
169+
}
168170
}
169171

170172
break;

0 commit comments

Comments
 (0)