2021-09-24 19:06:26 +09:00
|
|
|
// React
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
|
|
export const getName = async (props) => {
|
|
|
|
const uuid = props;
|
|
|
|
return fetch('https://api.ashcon.app/mojang/v2/user/' + uuid);
|
|
|
|
};
|
|
|
|
|
2021-09-24 19:07:48 +09:00
|
|
|
const RawPlayerName = async (req, res) => {
|
2021-09-24 19:06:26 +09:00
|
|
|
const { uuid } = req.query
|
|
|
|
const response = await getName(uuid);
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.status === 204 || response.status > 400) {
|
|
|
|
return res.status(200).send("404");
|
|
|
|
}
|
|
|
|
const username = data.username;
|
|
|
|
return res.status(200).json({
|
|
|
|
username,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-09-24 19:07:48 +09:00
|
|
|
export default RawPlayerName
|