I'm working on an OAuth2 Discord login to my game's index. I try to pull nickname to my client-side and my Discord bot directly change logged user's nickname to his game name. I have nickname on my PHP-based server-side with JSON data but I don't know how can I pull it to my client-side
Example PHP Code
$myobj->username = "Test";
$myJSON = json_encode($myobj);
echo $myJSON;```
And my Javascript code:
const express = require('express');
const Discord = require('discord.js');
const client = new Discord.Client();
const app = express();
const passport = require("passport");
const { Strategy } = require("passport-discord");
const session = require("express-session");
app.use(passport.initialize());
app.use(passport.session());
passport.serializeUser(async(user, done) => {
await (await client.guilds.cache.get("guildID").members.fetch(user.id)).roles.add("roleID")
await (await client.guilds.cache.get("guildID").members.fetch(user.id)).setNickname(PHP DATA TO HERE)
return done(null, user)
});