diff --git a/packages/web3-providers/src/kv/index.ts b/packages/web3-providers/src/kv/index.ts index a5ab360ec6f7..f19115e85d02 100644 --- a/packages/web3-providers/src/kv/index.ts +++ b/packages/web3-providers/src/kv/index.ts @@ -6,21 +6,6 @@ import { KV_ROOT_URL } from './constants' export class JSON_Storage implements StorageAPI.Storage { constructor(private prefix: string) {} - async set(key: string, value: T) { - await fetch( - urlcat(KV_ROOT_URL, 'api/:name', { - name: `${this.prefix}_${key}`, - }), - { - method: 'PUT', - mode: 'cors', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(value), - }, - ) - } async get(key: string) { try { return fetchJSON( @@ -29,7 +14,7 @@ export class JSON_Storage implements StorageAPI.Storage { }), { method: 'GET', - mode: 'cors', + mode: 'no-cors', headers: { 'Content-Type': 'application/json', }, @@ -39,6 +24,22 @@ export class JSON_Storage implements StorageAPI.Storage { return } } + + async set(key: string, value: T) { + await fetch( + urlcat(KV_ROOT_URL, 'api/:name', { + name: `${this.prefix}_${key}`, + }), + { + method: 'PUT', + mode: 'cors', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(value), + }, + ) + } } export class KeyValueAPI implements StorageAPI.Provider {