Back to Library
NGL
js • 1/27/2026
13
const axios = require("axios");
async function submitNgl(url, text) {
try {
const parsedUrl = new URL(url);
const username = parsedUrl.pathname.split("/").filter(Boolean).pop();
if (!username) {
throw new Error("Invalid URL: Unable to extract username.");
}
const postData = new URLSearchParams({
username: username,
question: text,
deviceId: "0", // Default device ID
gameSlug: "",
referrer: "",
});
const axiosConfig = {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Accept: "*/*",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36",
Referer: url,
},
timeout: 30000,
};
const { data } = await axios.post(
"https://ngl.link/api/submit",
postData.toString(),
axiosConfig
);
return data;
} catch (error) {
throw new Error(error.response?.data?.message || error.message || "Request Failed");
}
}
module.exports = { submitNgl };