Skip to content

Commit

Permalink
attach token
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Jun 24, 2024
1 parent 385f5dd commit 5346824
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/ReductionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ const ReductionHistory: React.FC = () => {

const fetchReductions = useCallback(async (): Promise<void> => {
try {
const token = localStorage.get('scigateway:token');
const offset = currentPage * rowsPerPage;
const query = `limit=${rowsPerPage}&offset=${offset}&order_by=${orderBy}&order_direction=${orderDirection}&include_runs=true`;
const response = await fetch(`${fiaApiUrl}/instrument/${selectedInstrument}/reductions?${query}`);
const response = await fetch(`${fiaApiUrl}/instrument/${selectedInstrument}/reductions?${query}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
});
const data = await response.json();
setReductions(data);
} catch (error) {
Expand Down
7 changes: 5 additions & 2 deletions src/ValueEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ const ValueEditor: React.FC = () => {
const fiaApiUrl = process.env.REACT_APP_FIA_REST_API_URL;

const fetchReduction = useCallback(async (): Promise<void> => {
const token = localStorage.get('scigateway:token');
try {
setLoading(true);
const response = await fetch(`${fiaApiUrl}/reduction/${reductionId}`);
const response = await fetch(`${fiaApiUrl}/reduction/${reductionId}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
});
const data = await response.json();
console.log('Fetching reduction', data);
if (data && data.script && data.script.value) {
setScriptValue(data.script.value);
}
Expand Down

0 comments on commit 5346824

Please sign in to comment.