make api request with auth

This commit is contained in:
Eric Rosenbaum 2021-07-15 15:20:28 -04:00
parent d1fdf9556d
commit a55442d07f

View file

@ -2,7 +2,7 @@ import keyMirror from 'keymirror';
import api from '../../../lib/api';
import {curators, managers} from './redux-modules';
import {selectUsername} from '../../../redux/session';
import {selectUsername, selectToken} from '../../../redux/session';
import {selectStudioId, setRoles, setInfo} from '../../../redux/studio';
import {withAdmin} from '../../../lib/admin-requests';
@ -190,13 +190,14 @@ const acceptInvitation = () => ((dispatch, getState) => new Promise((resolve, re
const transferOwnership = (newOwnerName, newOwnerId) => ((dispatch, getState) => new Promise((resolve, reject) => {
const state = getState();
const studioId = selectStudioId(state);
const token = selectToken(state);
newOwnerName = newOwnerName.trim();
api({
uri: `/studios/${studioId}/transfer-ownership/${newOwnerName}`,
method: 'PUT',
authentication: token,
withCredentials: true,
useCsrf: true,
host: '' // Not handled by the API, use existing infrastructure
useCsrf: true
}, (err, body, res) => {
const error = normalizeError(err, body, res);
if (error) return reject(error);