auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
if(event.method === 'GET') {
let html = `
<html>
<head></head>
<body>
<div id="app">
<p>
<input v-model="name"> <button @click="sendToAPI">Process</button>
</p>
<p>
Result: {{ result }}
</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
const app = new Vue({
el:'#app',
data: {
name:'',
result:''
},
methods: {
async sendToAPI() {
let resp = await fetch("${event.url}", {
method:"post",
body: JSON.stringify({name:this.name})
});
let data = await resp.json();
this.result = data.response;
}
}
});
</script>
</body>
</html>
`;
$respond({
status: 200,
headers: {
"Content-Type": "text/html; charset=UTF-8"
},
body: html,
});
$end();
}
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
if(event.method === 'POST') {
let name = 'Nameless';
if(event.body.name) name = event.body.name;
$respond({
headers: {
"Content-Type":"application/json"
},
body: {"response":`Hello ${name}`}
});
}