Skip to content

Commit

Permalink
Try to connect with WikiData
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiollende committed Mar 21, 2024
1 parent 8ffdf38 commit 5ae236a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
12 changes: 9 additions & 3 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ app.post('/edituser', async (req, res) => {
}
});

app.get('/WikiData/GetCapitalsQuestions', async (_req, res) => {
app.get('/GetCapitalsQuestions', async (_req, res) => {
try {
// Forward the edit user request to the user service
console.log(process.env.WIKIDATA_SERVICE_URL);
const wikiResponse = await axios.get(wikidataServiceUrl + '/WikiData/GetCapitalsQuestions');
res.json(wikiResponse.data);
const wikiResponse = await axios.get(wikidataServiceUrl + '/WikiData/GetCapitalsQuestions', { timeout: 5000 });
if (wikiResponse.status !== 200) {
console.error('Error with the wikidata service:', wikiResponse.status);
res.status(wikiResponse.status).json({ error: 'Error with the wikidata service' });
} else {
res.json(wikiResponse.data);
}
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Error with the gateway service' });
}
});

Expand Down
14 changes: 12 additions & 2 deletions webapp/src/stores/playing-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,25 @@ const API_URL = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000';

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

// const retrieveQuestionss = () => {
// 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 useGameQuestions = create<GameQuestions>((set) => ({
questions: [],
setQuestions: (questions: any[]) => set({ questions: questions }),
Expand Down
2 changes: 0 additions & 2 deletions wikidata_service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG BUILD_CONFIGURATION=Release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:7259;http://localhost:5276"
"applicationUrl": "http://localhost:7259"
},
"IIS Express": {
"commandName": "IISExpress",
Expand Down

0 comments on commit 5ae236a

Please sign in to comment.