Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ yarn add react-netlify-identity
- `logoutUser()`
- `requestPasswordRecovery(email: string)`
- `recoverAccount(token: string, remember?: boolean | undefined)`
- `updateUser(fields: Object)`
- `updateUser(fields: { data: object })`
- `getFreshJWT()`
- `authedFetch(endpoint: string, obj = {})` (a thin axios-like wrapper over `fetch` that has the user's JWT attached, for convenience pinging Netlify Functions with Netlify Identity)

Expand Down
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type ReactNetlifyIdentityAPI = {
token: string,
remember?: boolean | undefined
) => Promise<User>;
updateUser: (fields: Object) => Promise<User | undefined>;
updateUser: (fields: { data: object }) => Promise<User | undefined>;
getFreshJWT: () => Promise<string>;
authedFetch: {
get: (endpoint: string, obj?: {}) => Promise<any>;
Expand Down Expand Up @@ -153,12 +153,12 @@ export function useNetlifyIdentity(
goTrueInstance.requestPasswordRecovery(email);
const recoverAccount = (token: string, remember?: boolean | undefined) =>
goTrueInstance.recover(token, remember);
const updateUser = (fields: Object) => {
const updateUser = (fields: { data: object }) => {
if (user == null) {
throw new Error('No current user found - are you logged in?');
} else {
return user!
.update(fields) // e.g. { email: "example@example.com", password: "password" }
.update(fields) // e.g. { data: { email: "example@example.com", password: "password" } }
.then(_setUser);
}
};
Expand Down