export default {
async fetch(request, env, ctx) {
if (request.headers.get('authorization') !== 'abc') {
return new Response('not authorized', { status: 401 })
}
try {
const key = "registrationChallenge/bob4@foo.bar"
const value = Math.random().toString()
const firstGet = await env.KV.get(key) ?? "<null>"
await env.KV.put(key, value)
const secondGet = await env.KV.get(key) ?? "<null>"
return new Response(JSON.stringify({
key,
firstGet,
updated: value,
secondGet,
}, undefined, 2));
} catch (e) {
return new Response(e.stack, { status: 500 });
}
},
};
export default {
async fetch(request, env, ctx) {
if (request.headers.get('authorization') !== 'abc') {
return new Response('not authorized', { status: 401 })
}
try {
const key = "registrationChallenge/bob4@foo.bar"
const value = Math.random().toString()
const firstGet = await env.KV.get(key) ?? "<null>"
await env.KV.put(key, value)
const secondGet = await env.KV.get(key) ?? "<null>"
return new Response(JSON.stringify({
key,
firstGet,
updated: value,
secondGet,
}, undefined, 2));
} catch (e) {
return new Response(e.stack, { status: 500 });
}
},
};