Skip to content

Instantly share code, notes, and snippets.

@kaueDM
Created July 12, 2019 03:30
Show Gist options
  • Save kaueDM/a52779c42f475e2e7e63e2afab66f96c to your computer and use it in GitHub Desktop.
Save kaueDM/a52779c42f475e2e7e63e2afab66f96c to your computer and use it in GitHub Desktop.
import idx from 'idx'
import CreateInterface from './interfaces/CreateInterface'
const create: CreateInterface = async (getPublicResource, register) => {
const method = 'POST'
const endpoint = '/auth/sign_in'
const data = register
const response = await getPublicResource({ method, endpoint, data })
const headers = response.headers || {}
delete headers['cache-control']
delete headers['content-type']
return idx(response, _ => _.data.user)
? { user: response.data.user, headers }
: response
}
export default create
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment