@@ -3,7 +3,7 @@ const app = express()
33const netApi = require ( './proxy.js' )
44const port = process . env . PORT || 8080
55const cors = require ( 'cors' )
6- const fetch = require ( 'node-fetch' )
6+ const axios = require ( 'axios' ) ;
77
88app . use ( cors ( ) )
99app . use ( netApi ( { allowOrigin : '*' } ) )
@@ -13,21 +13,23 @@ app.use("/proxyCheck",(req,res,next)=>{
1313} )
1414
1515app . get ( "/getId" , ( req , res , next ) => {
16- fetch ( `https://api.mojang.com/users/profiles/minecraft/${ req . query . nick } ` )
17- . then ( data => data . json ( ) )
18- . then ( player => { res . send ( player . id ) } )
19- . catch ( error => {
20- res . send ( "ERR" )
21- } )
16+ axios . get ( `https://api.mojang.com/users/profiles/minecraft/${ req . query . nick } ` , { responseType : 'json' } )
17+ . then ( function ( response ) {
18+ res . send ( response . data . id )
19+ } )
20+ . catch ( function ( error ) {
21+ res . send ( "ERR" )
22+ } )
2223} )
2324
2425app . get ( "/getSkin" , ( req , res , next ) => {
25- fetch ( `https://sessionserver.mojang.com/session/minecraft/profile/${ req . query . id } ?legacy=true` )
26- . then ( data => data . json ( ) )
27- . then ( player => { res . json ( player ) } )
28- . catch ( error => {
29- res . send ( "ERR" )
30- } )
26+ axios . get ( `https://sessionserver.mojang.com/session/minecraft/profile/${ req . query . id } ?legacy=true` , { responseType : 'json' } )
27+ . then ( function ( response ) {
28+ res . json ( response . data )
29+ } )
30+ . catch ( function ( error ) {
31+ res . send ( "ERR" )
32+ } )
3133} )
3234
3335app . listen ( port , ( ) => {
0 commit comments