mirror of
				https://github.com/yude-jp/yude.jp
				synced 2025-11-04 05:38:33 +09:00 
			
		
		
		
	Remove /api/PlayerName
This commit is contained in:
		@@ -1,23 +0,0 @@
 | 
			
		||||
// 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);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const RawPlayerName = async (req, res) => {
 | 
			
		||||
    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,
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default RawPlayerName
 | 
			
		||||
@@ -9,7 +9,7 @@ const fetcher = (url) => fetch(url).then((res) => res.json())
 | 
			
		||||
function App (props) {
 | 
			
		||||
  const uuid = props;
 | 
			
		||||
  const { data, error } = useSwr(
 | 
			
		||||
    uuid.uuid ? `/api/PlayerName/${uuid.uuid}` : null,
 | 
			
		||||
    uuid.uuid ? `https://api.ashcon.app/mojang/v2/user/${uuid.uuid}` : null,
 | 
			
		||||
    fetcher
 | 
			
		||||
  )
 | 
			
		||||
  
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@
 | 
			
		||||
 import { useRouter } from 'next/router'
 | 
			
		||||
 
 | 
			
		||||
 // Data fetching
 | 
			
		||||
 import Players from '../../components/Minecraft/Players'
 | 
			
		||||
 import useSwr from 'swr'
 | 
			
		||||
 const fetcher = (url) => fetch(url).then((res) => res.json())
 | 
			
		||||
 
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ export default function UUID() {
 | 
			
		||||
  const router = useRouter()
 | 
			
		||||
  const { uuid } = router.query
 | 
			
		||||
  const { data, error } = useSwr(
 | 
			
		||||
    uuid ? `/api/PlayerName/${uuid}` : null,
 | 
			
		||||
    uuid ? `https://api.ashcon.app/mojang/v2/user/${uuid}` : null,
 | 
			
		||||
    fetcher
 | 
			
		||||
  )
 | 
			
		||||
  if (error) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user