Secrets Store: cannot access via a binding variable.

I have setup my secrets in the Beta Secrets Store and the bindings are good, when I attempt to retrieve them I get an odd experience. I am calling it with typescript as the example suggests:
export default {
async fetch(request, env) {

const APIkey = await env.API_KEY.get()
export default {
async fetch(request, env) {

const APIkey = await env.API_KEY.get()
I receive an odd error:
Application error: TypeError: Failed to execute 'get' on 'Fetcher': parameter 1 is not of type 'string'.
Application error: TypeError: Failed to execute 'get' on 'Fetcher': parameter 1 is not of type 'string'.
Then I add a string (which is not how the example reads) and I get this:
export default {
async fetch(request, env) {

const APIkey = await env.API_KEY.get('API_KEY')
export default {
async fetch(request, env) {

const APIkey = await env.API_KEY.get('API_KEY')
and get this:
Application error: TypeError: Invalid URL: API_KEY
Application error: TypeError: Invalid URL: API_KEY
My experience is not aligning with the docs. Do I need to be on some beta version of the SDK? Thanks!!
1 Reply
cbschuld
cbschuldOP4w ago
FYI, this is solved it had something to do with my setup - I re-did a wrangler create and it works great.

Did you find this page helpful?