about summary refs log tree commit diff
path: root/src/state/queries
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/queries')
-rw-r--r--src/state/queries/index.ts5
-rw-r--r--src/state/queries/profile.ts13
2 files changed, 18 insertions, 0 deletions
diff --git a/src/state/queries/index.ts b/src/state/queries/index.ts
new file mode 100644
index 000000000..ae3d1595c
--- /dev/null
+++ b/src/state/queries/index.ts
@@ -0,0 +1,5 @@
+import {BskyAgent} from '@atproto/api'
+
+export const PUBLIC_BSKY_AGENT = new BskyAgent({
+  service: 'https://api.bsky.app',
+})
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts
new file mode 100644
index 000000000..c2cd19482
--- /dev/null
+++ b/src/state/queries/profile.ts
@@ -0,0 +1,13 @@
+import {useQuery} from '@tanstack/react-query'
+
+import {PUBLIC_BSKY_AGENT} from '#/state/queries'
+
+export function useProfileQuery({did}: {did: string}) {
+  return useQuery({
+    queryKey: ['getProfile', did],
+    queryFn: async () => {
+      const res = await PUBLIC_BSKY_AGENT.getProfile({actor: did})
+      return res.data
+    },
+  })
+}