Skip to content

Commit

Permalink
Fix: remove duplicate content type header (#537)
Browse files Browse the repository at this point in the history
* dispatch thrown response

* remove content type header

* add comment on the reliance on the graph client
  • Loading branch information
thewahome committed May 11, 2020
1 parent cd1f2fb commit 952e2af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/app/services/actions/query-action-creator-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ export async function anonymousRequest(dispatch: Function, query: IQuery) {
const escapedUrl = encodeURIComponent(query.sampleUrl);
const graphUrl = `https://proxy.apisandbox.msdn.microsoft.com/svc?url=${escapedUrl}`;
const sampleHeaders: any = {};

if (query.sampleHeaders) {
if (query.sampleHeaders && query.sampleHeaders.length > 0) {
query.sampleHeaders.forEach(header => {
if (header.name !== '' && header.value !== '') {
sampleHeaders[header.name] = header.value;
}
sampleHeaders[header.name] = header.value;
});
}

Expand Down Expand Up @@ -101,11 +98,14 @@ const makeRequest = (httpVerb: string, scopes: string[]): Function => {
const sampleHeaders: any = {};
sampleHeaders.SdkVersion = 'GraphExplorer/4.0';

if (query.sampleHeaders) {
if (query.sampleHeaders && query.sampleHeaders.length > 0) {
query.sampleHeaders.forEach(header => {
if (header.name !== '' && header.value !== '') {
sampleHeaders[header.name] = header.value;

// We are relying on the graph client to set the content type header.
if (header.name.toLowerCase() === 'content-type') {
return;
}
sampleHeaders[header.name] = header.value;
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/app/services/actions/samples-action-creators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export function fetchSamples(): Function {
const res = await response.json();
return dispatch(fetchSamplesSuccess(res.sampleQueries));
} catch (error) {
const errorCode = await error.text();
return dispatch(fetchSamplesError({ error: errorCode }));
return dispatch(fetchSamplesError({ error }));
}
};
}

0 comments on commit 952e2af

Please sign in to comment.