This JavaScript code interacts with the ChatGPT AI chatbot on the ChatGPT website. It sends a message to the chatbot and receives the response. The code uses Axios for making HTTP requests and Cheerio for web scraping.
API Crawled from chatgpt.ai Enjoy unlimited queries with no limits!
- Install the required libraries by running
npm install axios cheerio
. - Import the necessary libraries in your JavaScript code.
- Call the
chatgpt
function with your chat input as a parameter. - The function returns the response from the ChatGPT API.
Example Usage:
const axios = require('axios');
const cheerio = require('cheerio');
async function chatgpt(chat) {
try {
// ... (rest)
} catch (error) {
console.error(error);
return null;
}
}
(async () => {
const result = await chatgpt("who is elon musk");
console.log(result);
})();