diff --git a/frontend/src/api.js b/frontend/src/api.js index 4ff9348f..61d03d60 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -479,13 +479,29 @@ export default class API { } static async addPlaylist(values) { + let body = null; + if (values.uploaded_file) { + body = new FormData(); + for (const prop in values) { + body.append(prop, values[prop]); + } + } else { + body = { ...values }; + delete body.uploaded_file; + body = JSON.stringify(body); + } + const response = await fetch(`${host}/api/m3u/accounts/`, { method: 'POST', headers: { Authorization: `Bearer ${await API.getAuthToken()}`, - 'Content-Type': 'application/json', + ...(values.uploaded_file + ? {} + : { + 'Content-Type': 'application/json', + }), }, - body: JSON.stringify(values), + body, }); const retval = await response.json(); diff --git a/frontend/src/components/forms/M3U.jsx b/frontend/src/components/forms/M3U.jsx index 65c43f98..051826ac 100644 --- a/frontend/src/components/forms/M3U.jsx +++ b/frontend/src/components/forms/M3U.jsx @@ -23,10 +23,7 @@ const M3U = ({ playlist = null, isOpen, onClose }) => { const [file, setFile] = useState(null); const [profileModalOpen, setProfileModalOpen] = useState(false); - console.log(playlist); - const handleFileChange = (file) => { - console.log(file); if (file) { setFile(file); }