// Example posting a text URL:
(async function() {
const resp = await fetch('https://api.deepai.org/api/cyberpunk-generator', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: "YOUR_TEXT_URL",
})
});
const data = await resp.json();
console.log(data);
})()
// Example posting file picker input text (Browser only):
document.getElementById('yourFileInputId').addEventListener('change', async function() {
const file = this.files[0];
const formData = new FormData();
formData.append('text', file);
const resp = await fetch('https://api.deepai.org/api/cyberpunk-generator', {
method: 'POST',
headers: {
'api-key': 'YOUR_API_KEY'
},
body: formData
});
const data = await resp.json();
console.log(data);
});
// Example posting a local text file (Node.js only):
const fs = require('fs');
const axios = require('axios');
(async function() {
const fileStream = fs.createReadStream('/path/to/your/file.txt');
const resp = await axios.post('https://api.deepai.org/api/cyberpunk-generator', fileStream, {
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
}
});
console.log(resp.data);
});
// Example directly sending a text string:
(async function() {
const resp = await fetch('https://api.deepai.org/api/cyberpunk-generator', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
text: "YOUR_TEXT_HERE",
})
});
const data = await resp.json();
console.log(data);
})()