0
0
mirror of https://github.com/yude-jp/yude.jp synced 2025-10-13 11:48:37 +09:00

Fix page title @ /minecraft/players/[uuid]

This commit is contained in:
2021-09-24 19:06:26 +09:00
parent a4982c7ef3
commit e3e4cc5a5e
5 changed files with 91 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
function App (props) {
const uuid = props;
const [data, setData] = useState({ hits: [] });
useEffect(() => {
const fetchData = async () => {
let result = null;
try {
result = await axios('https://api.ashcon.app/mojang/v2/user/' + uuid.uuid);
setData(result.data);
} catch (err) {
result = 404;
setData(result);
}
};
fetchData();
}, []);
if (data === undefined){
console.log("[Minecraft: UUID to player's name] データの取得に失敗しました。 / Failed to retrieve data.")
return <>取得中...</>
}else {
if (data === 404) {
return <>404</>
} else {
return (
<>{data.username.toString()}</>
)
}
};
}
export default App;

View File

@@ -1,6 +1,6 @@
import Online from './Online'
import Head from './Head'
import GetName from './GetName'
import PlayerNameHolder from './PlayerNameHolder'
function App (props) {
const uuid = props;
@@ -12,7 +12,7 @@ function App (props) {
</div>
<div className="w-5"></div>
<div>
<p className="text-2xl text-mono"><GetName uuid={uuid.uuid} /></p>
<p className="text-2xl text-mono"><PlayerNameHolder uuid={uuid.uuid} /></p>
<p><Online uuid={uuid.uuid} /></p>
</div>
</div>