Created
July 12, 2019 03:30
-
-
Save kaueDM/a52779c42f475e2e7e63e2afab66f96c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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