Trying to use D1 for my project. But getting an error
Hello everyone. I am new to cloudflare stuff and started experimenting with workers.
Im trying to publish a Pastebin like app so I can store pastes in it and share those.
https://gist.github.com/frontlineroleplaysrilanka/7e8e8f39e214f49603f2407693b25caa
Here is the current code of index.js and im trying to utilize the D1 database in it. But when I try to deploy it, an error comes which shows:
Any help please ๐ ?
Thanks.
Gist
Paste App but using D1
Paste App but using D1. GitHub Gist: instantly share code, notes, and snippets.
3 Replies
You need to convert your Worker to Module Syntax: https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/#migrate-from-service-workers-to-es-modules
Cloudflare Docs
Migrate from Service Workers to ES Modules ยท Cloudflare Workers docs
Write your Worker code in ES modules syntax for an optimized experience.
Just started experimenting. Ill try to understand this.
Thanks for the help โค๏ธ ๐
Fixed everything.
Thanks again and really appreciate your support. โค๏ธ
Happy to help!