Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed the reconciliation service request method to post,added the r… #2

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/ReconciliationService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { fetchJsonpParams, fetchParams } from './utils.js';
import { fetchJsonpParams, fetchParams , postParams , postJsonpParams } from './utils.js';
import { specVersions } from './JsonSchemas.js';
import { getSchema } from './JsonValidator.js';

Expand All @@ -24,6 +24,10 @@ export default class ReconciliationService {
getFetcher() {
return this.cors ? fetchParams : fetchJsonpParams;
}

postFetcher() {
return this.cors ? postParams : postJsonpParams;
}
}


4 changes: 2 additions & 2 deletions src/TestBench.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export default class TestBench extends React.Component {
return;
}
this.setState({reconResults: 'fetching'});
let fetcher = this.props.service.getFetcher();
fetcher(this.formulateQueryUrl(), {timeout: 20000})
let fetcher = this.props.service.postFetcher();
fetcher({url:this.props.service.endpoint,queries:JSON.stringify({q0: this.formulateReconQuery()})})
.then(result => result.json())
.then(result =>
this.setState({
Expand Down
25 changes: 25 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,31 @@ export const fetchParams = (baseUrl, params) => {
return fetch(addParams(baseUrl, params));
}

export const postJsonpParams = ({url,queries}) => {
return fetchJsonp(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
queries
})
});
}


export const postParams = ({url,queries}) => {
return fetch(url, {
method:"POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
queries
})
});
}

export const jsonTheme = {
scheme: 'monokai',
author: 'wimer hazenberg (http://www.monokai.nl)',
Expand Down
Loading