KV_NAMESPACE.put() promise is not returning anything

Hello, docs says the method put is a promise but it’s always undefined no matter the result.

const response = await KV_NAMESPACE.put(validKey, validData)
console.log(response)

If I use a valid key the record gets created/updated as expected but I get nothing from the await, the same with a wrong key i.e put(undefined, validData)… Am I doing something wrong?

dependencies:
"@cloudflare/wrangler": "^1.17.0"

Thanks for the help cloud people.

This is expected behaviour. The promise does indeed not return anything. If the creation/update had failed, it would have thrown an exception here. So, this is good! It was a success

I’m not sure what you mean by an invalid key, if it isn’t there already, it will just be created.

1 Like

Oh, I see now, thank you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.