I am calling a Patch Request that takes 30 - 40 secs from the backend to resolve
const handleSendClick = (data: any) => {
const requiredLanguages = Array.isArray(data.required_languages)
? data.required_languages
: [data.required_languages];
const status = requiredLanguages.reduce((acc: any, lang: any) => {
acc[lang] = "pending";
return acc;
}, {});
const resultObject = {
source_lang: data.source_lang,
required_languages: requiredLanguages,
status: status,
single_speaker: data.single_speaker === "enable",
is_active: true,
s3_path: videoMeta.s3_url,
save_action: true,
multi_audio: false,
};
updateVideo(resultObject, videoMeta.id).then((res) => {
if (res) {
dispatch(setInputType(""));
generateSourceTranscription(project_id)
.then((res) => {
dispatch(setTranscript(true));
generateTranscript(res);
})
.catch((err) => {
dispatch(setTranscript(false));
console.log(err);
});
}
});
};
and behind the scenes my request looks like this
export const updateVideo = async (payload: any, id: string) => {
try {
const { data } = await axios.patch(
`url/video_metadata/${id}/`,
payload,
{ timeout: 60000 }
);
return data;
} catch (err) {
console.error(err);
toastErr(err);
}
};
now at first the video doesn't patch but when i am trying again the request goes through and i need to make sure that the request goes through the first time as i am hitting the api from frontend the backend process is started and i am not getting the response on the frontend side
This is likely an Error Caused By the http error. Check If you are using http or https and if not then it's most likely a bug from the backend. check the backend api calls frequently on an ap platform like postman like you would in a normal browser if the socket connection is breaking, it'll result in this Error. Posting this after spending two days on this. If You are on Firefox the error message will be something like this