diff --git a/webapp/src/components/questionView/CreationHistoricalRecord.js b/webapp/src/components/questionView/CreationHistoricalRecord.js index 68ceb4f5..3bdb6370 100644 --- a/webapp/src/components/questionView/CreationHistoricalRecord.js +++ b/webapp/src/components/questionView/CreationHistoricalRecord.js @@ -39,29 +39,26 @@ class CreationHistoricalRecord{ async sendRecord(user) { - const apiUrl = (process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000') + "/record"; - - const body = { - user:user, - game:this.record.game - } - try { + const apiUrl = (process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000') + "/record"; + + const body = { + user: user, + game: this.record.game + }; + + try { const response = await axios.post(apiUrl, body, { - headers: { - 'Content-Type': 'application/json' - } + headers: { + 'Content-Type': 'application/json' + } }); - - if (!response.ok) { - throw new Error('Error al enviar el registro'); - } - - const data = await response.json(); - console.log(data); - } catch (error) { - console.error('Error:', error); - } + + + console.log('Registro enviado:', response.data); + } catch (error) { + console.error('Error al enviar el registro:', error.message); } + } } export default CreationHistoricalRecord; diff --git a/webapp/src/components/ranking/RankingRetriever.js b/webapp/src/components/ranking/RankingRetriever.js index 41953d22..e22d2e08 100644 --- a/webapp/src/components/ranking/RankingRetriever.js +++ b/webapp/src/components/ranking/RankingRetriever.js @@ -12,7 +12,6 @@ class RankingRetriever{ try { const response = await axios.get(this.apiUrl + '/top10');//finding the top ten const receivedTopTenRanking = await response.data; - console.log(receivedTopTenRanking) return receivedTopTenRanking; } catch (error) { console.log(error) @@ -80,8 +79,7 @@ class RankingRetriever{ try { const response = await axios.get(this.apiUrl + '/'+user);//finding the top ten const receivedMyRanking = await response.data; - console.log(receivedMyRanking) - return receivedMyRanking; + return receivedMyRanking.userCompetitiveStats; } catch (error) { console.log(error) throw new Error(error); diff --git a/webapp/src/components/ranking/RankingView.js b/webapp/src/components/ranking/RankingView.js index 6d172024..f59a53ce 100644 --- a/webapp/src/components/ranking/RankingView.js +++ b/webapp/src/components/ranking/RankingView.js @@ -25,7 +25,7 @@ const RankingView = () => { } } - if(rankingData==null){ + if(rankingData==null || myRankingData == null){ getRanking(); } @@ -57,7 +57,7 @@ const RankingView = () => {