-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
27 lines (25 loc) · 824 Bytes
/
handler.js
File metadata and controls
27 lines (25 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const axios = require('axios');
module.exports.checkInternet = async (event) => {
try {
// Faz uma requisição para o Google para verificar se a internet está funcionando
const response = await axios.get('https://graph.facebook.com');
// Retorna o status e os dados da resposta da requisição
return {
statusCode: 200,
body: JSON.stringify({
message: 'Internet is working!',
status: response.status,
data: response.data, // Retorna o corpo da resposta de 'google.com'
}),
};
} catch (error) {
// Se a requisição falhar, a internet pode estar fora do ar
return {
statusCode: 500,
body: JSON.stringify({
message: 'No internet connection!',
error: error.message, // Inclui a mensagem de erro
}),
};
}
};