mirror of
https://github.com/yude-jp/yude.jp
synced 2025-04-13 02:24:51 +09:00
Change API source, error handling
This commit is contained in:
parent
b532bb04d3
commit
ccfd1761cc
@ -14,7 +14,7 @@ export default function Minecraft(props) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
const result = await axios(
|
const result = await axios(
|
||||||
'https://eu.mc-api.net/v3/server/ping/yude.jp',
|
'https://api.mcsrvstat.us/2/yude.jp',
|
||||||
);
|
);
|
||||||
setData(result.data);
|
setData(result.data);
|
||||||
};
|
};
|
||||||
@ -30,7 +30,7 @@ export default function Minecraft(props) {
|
|||||||
}else{
|
}else{
|
||||||
console.log(data)
|
console.log(data)
|
||||||
const status = data.online
|
const status = data.online
|
||||||
const player = data.players && data.players.now
|
const player = data.players && data.players.online
|
||||||
const playing = t('minecraft:playing', {count: player})
|
const playing = t('minecraft:playing', {count: player})
|
||||||
const no_one = t('minecraft:no_one')
|
const no_one = t('minecraft:no_one')
|
||||||
const offline = t('minecraft:offline')
|
const offline = t('minecraft:offline')
|
||||||
@ -38,7 +38,7 @@ export default function Minecraft(props) {
|
|||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
{(() => {
|
{(() => {
|
||||||
if (status) {
|
if (status) {
|
||||||
if (player == undefined) {
|
if (player == undefined || player == 0) {
|
||||||
return <span>{no_one}</span>
|
return <span>{no_one}</span>
|
||||||
} else {
|
} else {
|
||||||
return <span>{playing}</span>
|
return <span>{playing}</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user