Skip to content

How should we handle queries that require a user's password/username? #370

Discussion options

You must be logged in to vote

How about using the optional queryVariables parameter to send your decryption key through to the query function?

import { useQuery } from 'react-query'
import { requestAndDecryptUserContacts } from '../api/Users'
import { useAuth } from '../context/UserContext'

const userContactFetcher = (_, username, decryptionKey) =>
  requestAndDecryptUserContacts(username, decryptionKey)

export default function useContacts() {
  const { decryptionKey, username } = useAuth()

  return useQuery(['contacts', username], decryptionKey, userContactFetcher)
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@transmissions11
Comment options

@tannerlinsley
Comment options

@transmissions11
Comment options

Answer selected by transmissions11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants