Skip to content

Instantly share code, notes, and snippets.

@lmaccherone
Last active February 26, 2023 19:16
Show Gist options
  • Save lmaccherone/68d1b3de908062a93a6b91c5dbd8b76d to your computer and use it in GitHub Desktop.
Save lmaccherone/68d1b3de908062a93a6b91c5dbd8b76d to your computer and use it in GitHub Desktop.
async fetch(request) {
await this.hydrate()
const url = new URL(request.url)
if (url.search === '') {
return new Response(this.greeting)
} else {
this.name = url.searchParams.get('name')
this.state.storage.put('name', this.name)
this.greeting = `${this.state.id.toString()}: `
+ `Your name is ${this.name}. HELLO ${this.name.toUpperCase()}!`
this.state.storage.put('greeting', this.greeting)
return new Response(this.greeting)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment