import {actionPromise} from "./actionPromise";

export const actionUploadFile = (files) => async (dispatch) => {
    let formdata = new FormData();
    formdata.append("photo", files);
    return await dispatch(
        actionPromise(
            "upload",
            fetch("/upload", {
              method: "POST",
              headers: localStorage.authToken
                ? { Authorization: "Bearer " + localStorage.authToken }
                : {},
              body: formdata,
            }).then((res) => res.json())
        )
    );
};