Skip to content

Commit

Permalink
Changes wikidata call
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiollende committed Mar 21, 2024
1 parent b4c7353 commit 8ffdf38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
4 changes: 0 additions & 4 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ app.post('/login', async (req, res) => {
const authResponse = await axios.post(userServiceUrl + '/auth/login', req.body);
res.json(authResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
console.error(error);
}
});
Expand All @@ -38,7 +37,6 @@ app.post('/adduser', async (req, res) => {
const userResponse = await axios.post(userServiceUrl + '/user/adduser', req.body);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
console.error(error);
}
});
Expand All @@ -49,7 +47,6 @@ app.post('/edituser', async (req, res) => {
const userResponse = await axios.post(userServiceUrl + '/user/edituser', req.body);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
console.error(error);
}
});
Expand All @@ -61,7 +58,6 @@ app.get('/WikiData/GetCapitalsQuestions', async (_req, res) => {
const wikiResponse = await axios.get(wikidataServiceUrl + '/WikiData/GetCapitalsQuestions');
res.json(wikiResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
console.error(error);
}
});
Expand Down
18 changes: 10 additions & 8 deletions webapp/src/stores/playing-store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import axios from 'axios';
import {create} from 'zustand';
import { getCorrectlyAnsweredQuestions, getQuestionsAnswered } from '../services/auth-service';

Expand Down Expand Up @@ -58,14 +59,15 @@ interface GameQuestions{

const API_URL = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000';

const retrieveQuestions = () => {
console.log(`${API_URL}`);
return fetch(`${API_URL}/WikiData/GetCapitalsQuestions`)
.then((response) => response.json())
.catch((error) => {
console.error('There was a problem with the questions:', error);
return []; // Return an empty array in case of an error
});
export const retrieveQuestions = async () => {
try {
let response = await axios.get(`${API_URL}/WikiData/GetCapitalsQuestions`);
console.log('response:', response);
return response.data.json();
} catch (error) {
console.error('There was a problem with the questions:', error);
return [];
}
};

export const useGameQuestions = create<GameQuestions>((set) => ({
Expand Down

0 comments on commit 8ffdf38

Please sign in to comment.