omit token if null or falsy

This commit is contained in:
Ben Wheeler 2019-05-28 15:11:17 -04:00
parent 5a24e9d7d6
commit 975a9c9645

View file

@ -763,12 +763,16 @@ module.exports.getRemixes = id => (dispatch => {
});
});
module.exports.getProjectStudios = (id, ownerUsername, isAdmin, token) => (dispatch => {
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.FETCHING));
api({
uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`,
authentication: token
}, (err, body, res) => {
const opts = {
uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`
};
if (token) {
Object.assign(opts, {authentication: token});
}
api(opts, (err, body, res) => {
if (err) {
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR));
dispatch(module.exports.setError(err));