Skip to content

Commit

Permalink
fixed image update issue
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavchopraavataar committed Nov 7, 2023
1 parent d988855 commit 53f1f14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frontend/components/form/FormHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,16 @@ const FormHeader = ({ createMode, state, prevOptionIds }: iFormHeaderProps) => {
}

const onSave = async () => {
const form_data = new FormData()
console.log(state)
if (isPost(state)) {
Object.entries(state).forEach(([key, value]) => {
form_data.append(key, value)
})
}
const res = await doApiRequest(`/api/portal/${route}/${state.id}/`, {
method: 'PATCH',
body: state,
body: isPost(state) ? form_data : state,
})

if (res.ok) {
Expand Down
1 change: 1 addition & 0 deletions frontend/utils/fetch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function getApiUrl(path: string): string {
*/
export function doApiRequest(path: string, data?: any): Promise<Response> {
let formattedData = data
console.log(formattedData)
if (!formattedData) {
formattedData = {}
}
Expand Down

0 comments on commit 53f1f14

Please sign in to comment.