Hello everyone,
can anyone tell me how to access document data from within the structure builder?
```import client from "@sanity/client"
client.getDocument('tags').then(tags...
6 replies
Last updated: Dec 22, 2020
C
Hello everyone,can anyone tell me how to access document data from within the structure builder?
import client from "@sanity/client"
client.getDocument('tags').then(tags => {
console.log(`${tags.tagArray}`)
})
i get the error message: TypeError: _client.default.getDocument is not a function at Object.<anonymous> (/static/js/app.bundle.js :180469:17) at __webpack_require__ (/static/js/vendor.bundle.js :713:30) at fn (/static/js/vendor.bundle.js :118:20) at loadStructure (/static/js/app.bundle.js :179724:15) at DeskTool.derivePanes (/static/js/app.bundle.js :401564:56) at DeskTool.derivePanes (/static/js/app.bundle.js :441377:25) at DeskTool.componentDidMount (/static/js/app.bundle.js :401673:10) at DeskTool.componentDidMount (/static/js/app.bundle.js :441367:123) at commitLifeCycles (/static/js/vendor.bundle.js :23112:22) at commitLayoutEffects (/static/js/vendor.bundle.js :26101:7)
Dec 22, 2020, 10:43 AM
C
The default export of
@sanity/client
is a sanity client constructor, not a singleton. You need to construct a client, then you can access its documents