Skip to content

Commit

Permalink
Merge pull request #156 from NIH-NCPI/cors-bug
Browse files Browse the repository at this point in the history
Removed credentials from headers causing CORS error
  • Loading branch information
yelenacox authored Dec 13, 2024
2 parents 7cc6c19 + ebe3223 commit 863696a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 50 deletions.
1 change: 0 additions & 1 deletion src/components/Manager/FetchManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ontologyReducer } from './Utilitiy';
export const getAll = (vocabUrl, name, navigate) => {
return fetch(`${vocabUrl}/${name}`, {
method: 'GET',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
Expand Down
94 changes: 45 additions & 49 deletions src/components/Projects/Tables/TableDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,65 +132,61 @@ export const TableDetails = () => {
setLoading(true);
getById(vocabUrl, 'Table', tableId)
.then(data => {
if (data === null) {
navigate('/404');
} else {
setTable(data);
if (data) {
getById(vocabUrl, 'Table', `${tableId}/mapping`)
.then(data => setMapping(data.codes))
.catch(error => {
if (error) {
console.log(error, 'error');

notification.error({
message: 'Error',
description: 'An error occurred loading mappings.',
});
}
return error;
})
.then(() =>
getById(
vocabUrl,
'Terminology',
'ftd-concept-map-relationship'
).then(data => setRelationshipOptions(data.codes))
)
.then(() =>
fetch(`${vocabUrl}/Table/${tableId}/filter/self`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
)
.then(res => {
if (res.ok) {
return res.json();
} else {
throw new Error('An unknown error occurred.');
}
})
.then(data => {
setApiPreferences(data);
setTable(data);
if (data) {
getById(vocabUrl, 'Table', `${tableId}/mapping`)
.then(data => setMapping(data.codes))
.catch(error => {
if (error) {
console.log(error, 'error');

notification.error({
message: 'Error',
description: 'An error occurred loading mappings.',
});
}
return error;
})
.then(() =>
getById(
vocabUrl,
'Terminology',
'ftd-concept-map-relationship'
).then(data => setRelationshipOptions(data.codes))
)
.then(() =>
fetch(`${vocabUrl}/Table/${tableId}/filter/self`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.finally(() => setLoading(false));
} else {
setLoading(false);
}
)
.then(res => {
if (res.ok) {
return res.json();
} else {
throw new Error('An unknown error occurred.');
}
})
.then(data => {
setApiPreferences(data);
})
.finally(() => setLoading(false));
} else {
setLoading(false);
}
})
.catch(error => {
if (error) {
notification.error({
message: 'Error',
description: 'An error occurred loading table details.',
description: 'An error occurred loading the table.',
});
setLoading(false);
}
return error;
})
.finally(() => setLoading(false));
});
};

useEffect(() => {
Expand Down

0 comments on commit 863696a

Please sign in to comment.