Skip to content

Commit

Permalink
detecting internet connection
Browse files Browse the repository at this point in the history
  • Loading branch information
hiago08 committed Jul 17, 2023
1 parent aa6e969 commit db0bae8
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions scripts/glboardjs/GLBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export default class GLBoard {
//callback();

// const connection = await InternetConnection.checkConnection();
// if (!connection) {
// throw new Error(
// "Não foi possível carregar os dados do usuário pois não há conexão com a internet!"
// );
// }
if (!navigator.onLine) {
throw new Error(
"Não foi possível carregar os dados do usuário pois não há conexão com a internet!"
);
}

try {
const url =
Expand All @@ -52,13 +52,10 @@ export default class GLBoard {
"Esse usuário ainda não possui registros! Adicione informações."
);
} else {
callback();
//console.log(result);
this.data.game_data = result.game_data;
this.data.player_data = result.player_data;

// console.log(JSON.parse(result));
}
callback();
} catch (error) {
console.log(error);
}
Expand All @@ -70,11 +67,11 @@ export default class GLBoard {
async SEND_USER_DATA() {
//const connection = await InternetConnection.checkConnection();
// const url = "http://localhost:3000/glboard";
// if (!connection) {
// throw new Error(
// "Não foi possível carregar os dados do usuário pois não há conexão com a internet!"
// );
// }
if (!navigator.onLine) {
throw new Error(
"Não foi possível carregar os dados do usuário pois não há conexão com a internet!"
);
}

try {
const url =
Expand Down

0 comments on commit db0bae8

Please sign in to comment.