const axios = require('axios'); async function grammarcheck(text) { try { if (!text) throw new Error('Text is required.'); const { data: a } = await axios.post('https://app.essaypro.com/api/ai-tools/v1_0/grammar-checker/report/', { text: text, file: null }, { headers: { origin: 'https://paperwriter.com', referer: 'https://paperwriter.com/grammar-checker', 'user-agent': 'Mozilla/5.0 (Linux; Android 15; SM-F958 Build/AP3A.240905.015) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.86 Mobile Safari/537.36' } }); if (!a?.id) throw new Error('ID not found.'); while (true) { const { data } = await axios.get(`https://app.essaypro.com/api/ai-tools/v1_0/grammar-checker/report/${a.id}`, { origin: 'https://paperwriter.com', referer: 'https://paperwriter.com/grammar-checker', 'user-agent': 'Mozilla/5.0 (Linux; Android 15; SM-F958 Build/AP3A.240905.015) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.86 Mobile Safari/537.36' }); if (data?.status === 'completed') return data; await new Promise(res => setTimeout(res, 1000)); } } catch (error) { throw new Error(error.message); } } // Usage: grammarcheck(`The old lighthouse stood sentinel on the rugged cliff, its white-painted tower weathered by decades of salt spray and ocean winds. Each evening as the sun dipped below the horizon, painting the sky in brilliant streaks of orange and purple, lighthouse keeper would climb spiral staircase to ignite beacon that had guided countless sailors safely home. The rhythmic crash of waves against the rocks below created a hypnotic symphony, while seabirds circled overhead, their cries echoing through the salty air. Inside the keeper's cottage, warm light glowed from small windows, promising shelter and comfort against the wild, untamed beauty of the coastal landscape that stretched endlessly in all directions.`).then(console.log);