DEV Community

kyw
kyw

Posted on

Deepseek and ChatGPT can't get this right: How to update a CloudFlare KV pair with metadata

Current state-of-the-art generative AI was supposed to be able to give me straight answer for this. But ChatGPT and Deepseek kept giving me wrong answers and wasting even more of my time going back and forth than if I had just read the damn documentation myself.

So here is the straight answer from me, a human being, on how to update a specific Cloudflare KV pair along with updated metadata:

const url = `https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/storage/kv/namespaces/<NAMESPACE_ID>/values/<KV_KEY>`;

const formData = new FormData();
formData.append('value', <KV_VALUE>);
formData.append('metadata', JSON.stringify(<KV_METADATA_OBJ>));

const response = await fetch(url, {
   method: 'PUT',
   headers: {
     Authorization: `Bearer <API_TOKEN>`,
   },
   body: formData,
});

const result = await response.json();

console.log(result);
Enter fullscreen mode Exit fullscreen mode

Conclusion

Still no way I'm trusting 'AI'. They don't know what they are doing. GenAI won't get us to AGI and all that. We are doing AI wrong. Also check out my website to discover best movies from Wikipedia nobody else is recommending. That's all. Cheers.

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

Top comments (0)