I’m trying to develop a React-Native project. When I’m making a Patch request, I’m getting this Error.
LOG [SyntaxError: JSON Parse error: Unexpected end of input]
Error: ENOENT: no such file or directory, open ‘C:rootreact-nativepackagesreact-nativeReactAndroidhermes-engine.cxxReleasee4t6q3kux86_64libInternalBytecodeInternalBytecode.js’
at Object.openSync (node:fs:601:3)
at Object.readFileSync (node:fs:469:35)
at getCodeFrame (C:UsersfiyleStudioProjectsnurse-scheduling-mobilenurse_schedulingnode_modulesmetrosrcServer.js:868:18)
at Server._symbolicate (C:UsersfiyleStudioProjectsnurse-scheduling-mobilenurse_schedulingnode_modulesmetrosrcServer.js:945:22)
at Object.readFileSync (node:fs:469:35)
at getCodeFrame (C:UsersfiyleStudioProjectsnurse-scheduling-mobilenurse_schedulingnode_modulesmetrosrcServer.js:868:18)
at Server._symbolicate (C:UsersfiyleStudioProjectsnurse-scheduling-mobilenurse_schedulingnode_modulesmetrosrcServer.js:945:22)
at async Server._processRequest (C:UsersfiyleStudioProjectsnurse-scheduling-mobilenurse_schedulingnode_modulesmetrosrcServer.js:394:7) {
errno: -4058,
syscall: ‘open’,
code: ‘ENOENT’,
path: ‘C:rootreact-nativepackagesreact-nativeReactAndroidhermes-engine.cxxReleasee4t6q3kux86_64libInternalBytecodeInternalBytecode.js’
}
Here is my codes. Thank
export async function patchFetch(url: string, payload: any, credentials?: string |
null) {
const headers: { [key: string]: string } = {
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*",
};
if (credentials) {
headers['Authorization'] = `Basic ${credentials}`;
}
const requestOptions = await fetch(url, {
method: 'PATCH',
headers: headers,
body: JSON.stringify(payload),
});
const response = await requestOptions.json();
if (requestOptions.status === 200) {
return response;
} else if (requestOptions.status === 400) {
throw new Error("Bad Request");
} else if (requestOptions.status === 401) {
throw new Error("Unauthorized");
} else if (requestOptions.status === 403) {
throw new Error("Forbidden");
} else {
throw new Error("Something went wrong");
}}
export const swapShifts = async (id:string,credentials:string) => {
const url = `${BASE_URL}/api/exchange-shift-requests/${id}/accept`;
return await patchFetch(url,{},credentials);}
const acceptShift = () => {
if (selectedShift) {
swapShifts(selectedShift.id, credentials).then(() => {
setModalVisible(false);
setSelectedShift(null)
}
)
}}