// Using fetch API
fetch('https://translationapi.pages.dev/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
word: 'hello',
from: 'en',
to: 'es'
})
})
.then(response => response.json())
.then(data => {
console.log('Translation:', data);
// Access translation data
console.log('Main translation:', data.data);
})
.catch(error => console.error('Error:', error));
curl -X POST "https://translationapi.pages.dev/" \
-H "Content-Type: application/json" \
-d '{
"word": "hello",
"from": "en",
"to": "es"
}'