32 lines
881 B
JavaScript

import axios from 'axios'
import CONFIG from '@/core/config.js'
const updateTeam = async (team) => {
try {
const token = localStorage.getItem('access_token')
// Убираем id из тела запроса, он идет в URL
const { id, ...teamData } = team
console.log('Отправляем на сервер:', teamData)
const response = await axios.put(
`${CONFIG.BASE_URL}/teams/${id}`,
teamData,
{
withCredentials: true,
headers: {
Authorization: `Bearer ${token}`
}
}
)
console.log('Ответ от сервера:', response.data)
return response.data
} catch (error) {
throw new Error(error.response?.data?.detail || error.message)
}
}
export default updateTeam