Skip to content
function getChatGPTResponse() {
const query = document.getElementById('user-query').value;fetch('https://sumflur.com/chatgpt-proxy.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
messages: [{ role: 'user', content: query }]
})
})
.then(response => response.json())
.then(data => {
const message = data.choices[0]?.message?.content || 'No response';
document.getElementById('chatgpt-response').innerHTML = `${message}
`;
})
.catch(error => {
console.error('Error:', error);
document.getElementById('chatgpt-response').innerHTML = 'Something went wrong. Please try again later.
';
});
}