Unlock seamless workflows and faster delivery with our latest releases – get the details

Issue with setting up client to automatically upload wallet address, resolved with correction of dataset.

16 replies
Last updated: May 26, 2022
hello - I’m trying to set up a client to automatically upload the wallet address of users login in at the page. I’m not getting any errors at all - but it’s still not working. Nonetheless, I am still able to add documents from the schema.js, so I don’t think it’s a connection issue but rather CORS or the token.
May 20, 2022, 10:10 PM
Here’s the code for the client: import sanityClient from ‘@sanity/client’
export const client = sanityClient({
projectId: ‘1d0wbsuk’,
dataset: ‘production’,
apiVersion: ‘2022-05-19’,
token: ‘token code blah blah’,
useCdn: true,
ignoreBrowserTokenWarning: true,
})
May 20, 2022, 10:11 PM
useEffect(() => { if (!address) return

; (async () => {
const userDoc = {
_type: ‘users’,
_id: address,
userName: ‘Unnamed’,
walletAddress: address,
}

const result = await client.createIfNotExists(userDoc)
})()
}, [address])
May 20, 2022, 10:12 PM
Do you mean to have a semicolon before
(async () …
or is it meant to be a colon
:
May 20, 2022, 10:56 PM
Currently it is a
;
May 20, 2022, 10:57 PM
user Y
it was meant to be a ; according to the tutorial I follow (it’s pretty weird but that’s what it said to do), but I just removed it completely and it didn’t work either. If I change it to a colon it would ask me to add an expression.
May 20, 2022, 11:43 PM
Hmm, maybe you could post the tutorial and what part of it, and I’ll try to take a look over the weekend, I am heading out here shortly but I’ll do my best
May 20, 2022, 11:45 PM
user Y
would it be better the repo of the tutorial? https://github.com/CleverProgrammers/opensea-blockchain-youtube
May 20, 2022, 11:46 PM
Sure, Post both
May 20, 2022, 11:46 PM
https://youtu.be/x3eRXeMB-4k?t=2818 I started it from the moment he started to set up the client. He sent it to a file called lib
May 20, 2022, 11:47 PM
Ok, thanks I’ll take a look and follow up 🙇‍♂️
May 20, 2022, 11:48 PM
Awesome! Thank you so much
user Y
May 20, 2022, 11:48 PM
Hey
user Y
hope you’re doing well! Got a chance to check on this? 😁
May 23, 2022, 1:32 PM
Hello! Can anyone check on this thread to see what might be happening? Thanks! 🙇‍♂️
May 24, 2022, 2:24 PM
Sorry I missed this Aisen, we were a bit busy with the Structured Content conference and I forgot to follow up. Looking into this today
May 26, 2022, 5:32 PM
user Y
I was actually able to see what was wrong: I was using the wrong dataset 🤦‍♂️. So it was in fact working, but was sending it to a dataset called production instead of another one.
May 26, 2022, 5:36 PM
Ahh, we have all been there! Sorry for the delay anyway, but glad you got it resolved!! 👍
May 26, 2022, 5:38 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?