rbs@u2
Home
Php_u2
Html #1
Html #2
Html #3
Html #4
JS #1
JS #2
JS #3
JS #4
JsApi #1
JsApi #2
JsApi #3
JsApi #4
JsApi_u4
all-files
ori-v2
master
user
Logout
dsg
tool css
bootstrtap 5.3
auth
profile
waste
waste_group
venue
vehicle
event
comment
notification
discover
post
scanner
to_delete
const fetch = require('node-fetch'); const waste = {
Warning
: Undefined array key "name" in
/home/u340524018/domains/agniaga.com/public_html/sub/u2/cp/inc.filejsapi_u4.php
on line
291
Warning
: foreach() argument must be of type array|object, null given in
/home/u340524018/domains/agniaga.com/public_html/sub/u2/cp/inc.filejsapi_u4.php
on line
291
} module.exports = waste
Save
user_id)) { $idt=array( 'id'=>$id2, 'user_id'=>$js->user_id, 'lat'=>$js->lat, 'lng'=>$js->lng, 'label'=>$js->label, 'quantity'=>$js->quantity, 'category'=>$js->category, 'venue_id'=>$js->venue_id, 'remark'=>$js->remark, 'create_at'=>time(), ); //$dt['idt']=$idt; Insert($db,"wastes",$idt,0); if(isset($js->cover_photo) && $js->cover_photo!='') { $data=$js->cover_photo; $image_info = getimagesize($data); $extension = (isset($image_info["mime"]) ? explode('/', $image_info["mime"] )[1]: ""); //$dt['type']=$extension; $tmp_file=$ar['img_path']."users/tmp/".$js->user_id.".".$extension; $sub_folder=$ar['img_path']."/users/".$js->user_id; if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); } $sub_folder_p=$ar['img_path']."/users/".$js->user_id."/w"; if(!is_dir($sub_folder_p)){ mkdir($sub_folder_p, 0755); } $new_file=genRandom(10).".".$extension; //$dt['newfile']=$new_file; $data = str_replace('data:image/'.$extension.';base64,', '', $data); $data = str_replace(' ','+',$data); $bin = base64_decode($data); if ($bin === false) { //$dt['info']="convert invalid"; } //tmp file file_put_contents($tmp_file, $bin); ini_set('display_errors', '0'); resize_crop_image(1200,760,$tmp_file,$sub_folder_p."/".$new_file); unlink($tmp_file); $sql="SELECT `seq` from `images` where `modul`='waste' and `item_id`=".$id2." order by `seq` desc limit 1"; $res=mysqli_query($db,$sql); if(mysqli_num_rows($res)==1) { $r = mysqli_fetch_assoc($res); $seq2=$r['seq']+1; } else { $seq2=1; } $sql3="SELECT `id` from `images` order by `id` desc limit 1"; $res3=mysqli_query($db,$sql3); if(mysqli_num_rows($res3)==1) { $r3 = mysqli_fetch_assoc($res3); $id3=$r3['id']+1; } else { $id3=1; } $idt=array( 'id'=>$id3, 'modul'=>'waste', 'item_id'=>$id2, 'seq'=>$seq2, 'create_at'=>time(), 'path'=>$ar['imgurl']."users/".$js->user_id."/w/".$new_file, ); Insert($db,"images",$idt,0); $udt=array( 'cover_photo'=>$ar['imgurl']."users/".$js->user_id."/w/".$new_file, ); Update($db,"wastes",$udt,"id=".$id2,0); } $dt['success']=true; $dt['message']="Waste Added successfully"; $dt['id']=$id2; } else { $dt['error']=true; $dt['message']="Error Added Waste"; } //$dt['col']=$js; return $dt; } function add_waste_to_group($js){ global $ar,$db; $dt=array(); $sql2="SELECT `id` from `waste_to_group` order by `id` desc limit 1"; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res2)==1) { $r2 = mysqli_fetch_assoc($res2); $id2=$r2['id']+1; } else { $id2=1; } if(isset($js->user_id)) { $idt=array( 'id'=>$id2, 'waste_id'=>$js->waste_id, 'waste_group_id'=>$js->waste_group_id, 'create_at'=>time(), ); $udt=array( 'waste_group_id'=>$js->waste_group_id, ); InsertUpdate($db,"waste_to_group",$idt,$udt,0); $dt['success']=true; $dt['message']="Waste add to group successfully"; } else { $dt['error']=true; $dt['message']="Error add waste to group"; } return $dt; } function delete_waste($js){ global $ar,$db; $dt=array(); //{"user_id":"3","waste_id":"5"}; $sql="SELECT * from `wastes` where id=".$js->waste_id." and user_id=".$js->user_id; //$dt['sql']=$sql; $res=mysqli_query($db,$sql); if(mysqli_num_rows($res)>0) { $r=mysqli_fetch_assoc($res); $udt=array( 'del'=>1, ); Update($db,"wastes",$udt,"id=".$js->waste_id,0); //Delete($db,"waste","id=".$js->waste_id,0); $dt['success']=true; $dt['message']="Waste deleted successfully"; } else { $dt['error']=true; $dt['message']="Error delete waste"; } return $dt; } function edit_waste($js){ global $ar,$db; $dt=array(); if(isset($js->user_id)) { $udt=array( 'user_id'=>$js->user_id, 'lat'=>$js->lat, 'lng'=>$js->lng, 'label'=>$js->label, 'quantity'=>$js->quantity, 'category'=>$js->category, 'venue_id'=>$js->venue_id, 'remark'=>$js->remark, 'update_at'=>time(), ); Update($db,"wastes",$udt,"id=".$js->waste_id,0); if($js->cover_photo) { $data=$js->cover_photo; $image_info = getimagesize($data); $extension = (isset($image_info["mime"]) ? explode('/', $image_info["mime"] )[1]: ""); $dt['type']=$extension; $tmp_file=$ar['img_path']."users/tmp/".$js->user_id.".".$extension; $sub_folder=$ar['img_path']."/users/".$js->user_id; if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); } $sub_folder_p=$ar['img_path']."/users/".$js->user_id."/w"; if(!is_dir($sub_folder_p)){ mkdir($sub_folder_p, 0755); } $new_file=genRandom(10).".".$extension; $dt['newfile']=$new_file; $data = str_replace('data:image/'.$extension.';base64,', '', $data); $data = str_replace(' ','+',$data); $bin = base64_decode($data); if ($bin === false) { //$dt['info']="convert invalid"; } //tmp file file_put_contents($tmp_file, $bin); ini_set('display_errors', '0'); resize_crop_image(1200,760,$tmp_file,$sub_folder_p."/".$new_file); unlink($tmp_file); $sql="SELECT `seq` from `images` where `modul`='waste' and `item_id`=".$js->waste_id." order by `seq` desc limit 1"; $res=mysqli_query($db,$sql); if(mysqli_num_rows($res)==1) { $r = mysqli_fetch_assoc($res); $seq2=$r['seq']+1; } else { $seq2=1; } $sql3="SELECT `id` from `images` order by `id` desc limit 1"; $res3=mysqli_query($db,$sql3); if(mysqli_num_rows($res3)==1) { $r3 = mysqli_fetch_assoc($res3); $id3=$r3['id']+1; } else { $id3=1; } $idt=array( 'id'=>$id3, 'modul'=>'waste', 'item_id'=>$js->waste_id, 'seq'=>$seq2, 'create_at'=>time(), 'path'=>$ar['imgurl']."users/".$js->user_id."/w/".$new_file, ); Insert($db,"images",$idt,0); $udt=array( 'cover_photo'=>$ar['imgurl']."users/".$js->user_id."/w/".$new_file, ); Update($db,"wastes",$udt,"id=".$js->waste_id,0); } $dt['success']=true; $dt['message']="Update Waste successfully"; //$dt['id']=$id2; } else { $dt['error']=true; $dt['message']="Error Update Waste"; } //$dt['col']=$js; return $dt; } function get_user_waste($js){ global $ar,$db; $dt=array(); $sql="SELECT * from `wastes` where del=0 and user_id=".$js->user_id; //echo $sql8."
"; $res=mysqli_query($db,$sql); $total_items=mysqli_num_rows($res); $total_pages=ceil($total_items/$js->limit); $start=($js->page-1)*$js->limit; $sql2 = $sql." order by create_at desc limit ".$start.",".$js->limit; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res)>0) { $c=0; while($r1 = mysqli_fetch_assoc($res2)) { $dt['data'][$c]=$r1; $sql3="SELECT `path` as url from images where `item_id`='".$r1['id']."' and modul='waste'"; //echo $sql8."
"; $res3=mysqli_query($db,$sql3); $d=0; while($r3 = mysqli_fetch_assoc($res3)) { $dt['data'][$c]['media'][$d]=$r3; $d++; } $c++; } $dt['success']=true; $dt['page']=$js->page; $dt['limit']=$js->limit; $dt['total_items']=$total_items; $dt['total_pages']=$total_pages; } else { $dt['data']=[]; $dt['message']="No data found for the user"; } return $dt; } function get_waste($js){ global $ar,$db; $dt=array(); $sql="SELECT * from `wastes` where del=0 and id=".$js->waste_id; //echo $sql8."
"; $res=mysqli_query($db,$sql); $total_items=mysqli_num_rows($res); if(mysqli_num_rows($res)>0) { $r1 = mysqli_fetch_assoc($res); $dt['data']=$r1; $dt['success']=true; } else { $dt['data']=[]; $dt['message']="Data not available"; } return $dt; } function get_wastes($js){ global $ar,$db; $dt=array(); $sql="SELECT * from `wastes` where del=0 "; //echo $sql8."
"; $res=mysqli_query($db,$sql); $total_items=mysqli_num_rows($res); $total_pages=ceil($total_items/$js->limit); $start=($js->page-1)*$js->limit; $sql2 = $sql." order by create_at desc limit ".$start.",".$js->limit; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res)>0) { $c=0; while($r1 = mysqli_fetch_assoc($res2)) { $dt['data'][$c]=$r1; $sql3="SELECT * from images where `item_id`='".$r1['id']."' and modul='waste'"; //echo $sql8."
"; $res3=mysqli_query($db,$sql3); $d=0; while($r3 = mysqli_fetch_assoc($res3)) { $dt['data'][$c]['media'][$d]=$r3; $d++; } $c++; } $dt['success']=true; $dt['page']=$js->page; $dt['limit']=$js->limit; $dt['total_items']=$total_items; $dt['total_pages']=$total_pages; } else { $dt['data']=[]; $dt['message']="No tagged posts found for the user"; } return $dt; } function get_wastes_by_group($js){ global $ar,$db; $dt=array(); $sql="SELECT a.* from `wastes` a JOIN waste_to_group b ON a.id=b.waste_id where a.del=0 and b.waste_group_id=".$js->waste_group_id; //echo $sql8."
"; $res=mysqli_query($db,$sql); $total_items=mysqli_num_rows($res); $total_pages=ceil($total_items/$js->limit); $start=($js->page-1)*$js->limit; $sql2 = $sql." order by create_at desc limit ".$start.",".$js->limit; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res)>0) { $c=0; while($r1 = mysqli_fetch_assoc($res2)) { $dt['data'][$c]=$r1; $sql3="SELECT `path` as url,alt,width,height from images where `item_id`='".$r1['id']."' and modul='waste' order by seq"; //echo $sql8."
"; $res3=mysqli_query($db,$sql3); $d=0; while($r3 = mysqli_fetch_assoc($res3)) { $dt['data'][$c]['media'][$d]=$r3; $d++; } $c++; } $dt['success']=true; $dt['page']=$js->page; $dt['limit']=$js->limit; $dt['total_items']=$total_items; $dt['total_pages']=$total_pages; } else { $dt['data']=[]; $dt['message']="No tagged posts found for the user"; } return $dt; } function pick_waste($js){ global $ar,$db; $dt=array(); $sql2="SELECT `id` from `user_waste_picked` order by `id` desc limit 1"; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res2)==1) { $r2 = mysqli_fetch_assoc($res2); $id2=$r2['id']+1; } else { $id2=1; } $idt=array( 'id'=>$id2, 'waste_id'=>$js->waste_id, 'user_id'=>$js->user_id, 'create_at'=>time(), ); $udt=array( 'update_at'=>time(), ); Insert($db,"user_waste_picked",$idt,0); if(isset($js->cover_photo) && $js->cover_photo!='') { $data=$js->cover_photo; $image_info = getimagesize($data); $extension = (isset($image_info["mime"]) ? explode('/', $image_info["mime"] )[1]: ""); //$dt['type']=$extension; $tmp_file=$ar['img_path']."users/tmp/".$js->user_id.".".$extension; $sub_folder=$ar['img_path']."/users/".$js->user_id; if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); } $sub_folder_p=$ar['img_path']."/users/".$js->user_id."/uwp"; if(!is_dir($sub_folder_p)){ mkdir($sub_folder_p, 0755); } $new_file=genRandom(10).".".$extension; //$dt['newfile']=$new_file; $data = str_replace('data:image/'.$extension.';base64,', '', $data); $data = str_replace(' ','+',$data); $bin = base64_decode($data); if ($bin === false) { //$dt['info']="convert invalid"; } //tmp file file_put_contents($tmp_file, $bin); ini_set('display_errors', '0'); resize_crop_image(1200,760,$tmp_file,$sub_folder_p."/".$new_file); unlink($tmp_file); $sql="SELECT `seq` from `images` where `modul`='user_waste_picked' and `item_id`=".$id2." order by `seq` desc limit 1"; $res=mysqli_query($db,$sql); if(mysqli_num_rows($res)==1) { $r = mysqli_fetch_assoc($res); $seq2=$r['seq']+1; } else { $seq2=1; } $sql3="SELECT `id` from `images` order by `id` desc limit 1"; $res3=mysqli_query($db,$sql3); if(mysqli_num_rows($res3)==1) { $r3 = mysqli_fetch_assoc($res3); $id3=$r3['id']+1; } else { $id3=1; } $idt=array( 'id'=>$id3, 'modul'=>'user_waste_picked', 'item_id'=>$id2, 'seq'=>$seq2, 'create_at'=>time(), 'path'=>$ar['imgurl']."users/".$js->user_id."/uwp/".$new_file, ); Insert($db,"images",$idt,0); $udt=array( 'cover_photo'=>$ar['imgurl']."users/".$js->user_id."/uwp/".$new_file, ); Update($db,"user_waste_picked",$udt,"id=".$id2,0); } //$dt['success']=true; $dt['message']="Waste picked"; //kirim notif return $dt; } function update_pick_waste_cover_photo($js){ global $ar,$db; $dt=array(); $user_id=$js->user_id; $waste_id=$js->waste_id; if(isset($js->cover_photo) && $js->cover_photo!=''){ $data=$js->cover_photo; $image_info = getimagesize($data); $extension = (isset($image_info["mime"]) ? explode('/', $image_info["mime"] )[1]: ""); //$dt['type']=$extension; $tmp_file=$ar['img_path']."users/tmp/".$user_id.".".$extension; $sub_folder=$ar['img_path']."/users/".$user_id; if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); } $sub_folder_p=$ar['img_path']."/users/".$user_id."/uwp"; if(!is_dir($sub_folder_p)){ mkdir($sub_folder_p, 0755); } $new_file=genRandom(10).".".$extension; //$dt['newfile']=$new_file; $data = str_replace('data:image/'.$extension.';base64,', '', $data); $data = str_replace(' ','+',$data); $bin = base64_decode($data); if ($bin === false) { $dt['info']="convert invalid"; } //tmp file file_put_contents($tmp_file, $bin); ini_set('display_errors', '0'); resize_crop_image(1200,760,$tmp_file,$sub_folder_p."/".$new_file); unlink($tmp_file); $sql="SELECT `seq` from `images` where `modul`='user_waste_picked' and `item_id`=".$waste_id." order by `seq` desc limit 1"; $res=mysqli_query($db,$sql); if(mysqli_num_rows($res)==1) { $r = mysqli_fetch_assoc($res); $seq2=$r['seq']+1; } else { $seq2=1; } $sql2="SELECT `id` from `images` order by `id` desc limit 1"; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res2)==1) { $r2 = mysqli_fetch_assoc($res2); $id2=$r2['id']+1; } else { $id2=1; } $idt=array( 'id'=>$id2, 'modul'=>'user_waste_picked', 'item_id'=>$waste_id, 'seq'=>$seq2, 'create_at'=>time(), 'path'=>$ar['imgurl']."users/".$user_id."/uwp/".$new_file, ); Insert($db,"images",$idt,0); $udt4=array( 'cover_photo'=>$ar['imgurl']."users/".$user_id."/uwp/".$new_file, ); Update($db,"user_waste_picked",$udt4,"waste_id=".$js->waste_id,0); //$dt['idt']=$idt; //$dt['udt']=$udt4; $dt['success']=true; $dt['message']="Cover photo added"; } else { $dt['error']=true; $dt['message']="Error update cover photo"; } //$dt['image_url']=$ar['imgurl']."users/".$user_id."/w/".$new_file; return $dt; } function update_waste_cover_photo($js){ global $ar,$db; $dt=array(); $user_id=$js->user_id; $waste_id=$js->waste_id; $data=$js->cover_photo; if(isset($js->cover_photo) && $js->cover_photo!=''){ $image_info = getimagesize($data); $extension = (isset($image_info["mime"]) ? explode('/', $image_info["mime"] )[1]: ""); //$dt['type']=$extension; $tmp_file=$ar['img_path']."users/tmp/".$user_id.".".$extension; $sub_folder=$ar['img_path']."/users/".$user_id; if(!is_dir($sub_folder)){ mkdir($sub_folder, 0755); } $sub_folder_p=$ar['img_path']."/users/".$user_id."/w"; if(!is_dir($sub_folder_p)){ mkdir($sub_folder_p, 0755); } $new_file=genRandom(10).".".$extension; //$dt['newfile']=$new_file; $data = str_replace('data:image/'.$extension.';base64,', '', $data); $data = str_replace(' ','+',$data); $bin = base64_decode($data); if ($bin === false) { $dt['info']="convert invalid"; } //tmp file file_put_contents($tmp_file, $bin); ini_set('display_errors', '0'); resize_crop_image(1200,760,$tmp_file,$sub_folder_p."/".$new_file); unlink($tmp_file); $sql="SELECT `seq` from `images` where `modul`='waste' and `item_id`=".$waste_id." order by `seq` desc limit 1"; $res=mysqli_query($db,$sql); if(mysqli_num_rows($res)==1) { $r = mysqli_fetch_assoc($res); $seq2=$r['seq']+1; } else { $seq2=1; } $sql2="SELECT `id` from `images` order by `id` desc limit 1"; $res2=mysqli_query($db,$sql2); if(mysqli_num_rows($res2)==1) { $r2 = mysqli_fetch_assoc($res2); $id3=$r2['id']+1; } else { $id3=1; } $idt=array( 'id'=>$id3, 'modul'=>'waste', 'item_id'=>$js->waste_id, 'seq'=>$seq2, 'create_at'=>time(), 'path'=>$ar['imgurl']."users/".$user_id."/w/".$new_file, ); Insert($db,"images",$idt,0); $udt=array( 'cover_photo'=>$ar['imgurl']."users/".$user_id."/w/".$new_file, ); Update($db,"wastes",$udt,"id=".$js->waste_id,0); //$dt['idt']=$idt; //$dt['udt']=$udt; $dt['success']=true; $dt['message']="Cover photo update"; } else { $dt['error']=true; $dt['message']="Error update cover photo"; } //$dt['image_url']=$ar['imgurl']."users/".$user_id."/w/".$new_file; return $dt; } ?>
Save
import { API_URL, TIMEOUT_MS_HIGHER } from "./consts.js" import { getSessionUser } from "./auth.js"; export const addWaste = async (data) => { try { const user = await getSessionUser(); if (!user || !user.id) return null; const response = await fetch(`${API_URL}/waste/add-waste`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, ...data }), }); const res = await response.json(); return res; } catch (e) { console.error("Error add waste", e.message); return null; } }; export const addWasteToGroup = async (wasteGroupId, wasteId) => { try { const user = await getSessionUser(); if (!user || !user.id) return null; const response = await fetch(`${API_URL}/waste/add-waste-to-group`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, waste_group_id: wasteGroupId, waste_id: wasteId }), }); const res = await response.json(); return res; } catch (e) { console.error("Error add waste to vehicle", e.message); return null; } }; export const deleteWaste = async (wasteId) => { const user = await getSessionUser() if (!user) return const response = await fetch(`${API_URL}/waste/delete-waste`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, waste_id: wasteId }), }) const data = await response.json() return data } export const editWaste = async (wasteId, data) => { try { const user = await getSessionUser(); if (!user || !user.id) return null; const response = await fetch(`${API_URL}/waste/edit-waste`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, waste_id: wasteId, ...data }), }); const res = await response.json(); return res; } catch (e) { console.error("Error updating waste", e.message); return null; } }; export const getWasteByUserId = async (profilId, page = 1, limit = 10) => { const response = await fetch(`${API_URL}/waste/get-user-waste`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: profilId, page, limit }), }) const data = await response.json() if (response.status !== 200) { return { data: [], total_pages: 0, page: 1, limit } } return data } export const getWasteById = async (wasteId) => { const user = await getSessionUser(); const response = await fetch(`${API_URL}/waste/get-waste`, { cache: "no-cache", method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ waste_id: wasteId, user_id: user.id }), }); const data = await response.json(); if (response.status !== 200) { throw new Error(data.message); } return data; } export const getWastes = async (page = 1, limit = 10) => { const response = await fetch(`${API_URL}/waste/get-wastes`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, page, limit }), }) const data = await response.json() if (response.status !== 200) { return { data: [], total_pages: 0, page: 1, limit } } return data } export const getWastesByGroup = async (wasteGroupId, page = 1, limit = 10) => { const response = await fetch(`${API_URL}/waste/get-wastes-by-group`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, waste_group_id: wasteGroupId, page, limit }), }) const data = await response.json() if (response.status !== 200) { return { data: [], total_pages: 0, page: 1, limit } } return data } export const pickWaste = async (wasteId, ownerId) => { const user = await getSessionUser() if (!user) return try { const response = await fetch(`${API_URL}/waste/pick-waste`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, waste_id: wasteId, owner_id: ownerId }), }) const data = await response.json() if (!response.ok || response.status !== 200) { throw new Error(data.message) } return data } catch (e) { console.error("Error liking comment") throw new Error(e.message) } } export const updatePickWasteCoverImage = async (wasteId, coverPhoto) => { try { const user = await getSessionUser(); if (!user) return; setTimeout(() => { controller.abort() }, TIMEOUT_MS_HIGHER) const response = await fetch(`${API_URL}/waste/update-pick-waste-cover-photo`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, waste_id: wasteId, cover_photo: coverPhoto }) }); const data = await response.json(); return data; } catch (error) { if (error.name === 'AbortError') { throw { message: "Failed to update cover photo, your connection timed out", name: "TimeOutError" }; } else { throw error; // Rethrow any other errors } } }; export const updateWasteCoverImage = async (wasteId, cover_photo) => { try { const user = await getSessionUser(); if (!user) return; setTimeout(() => { controller.abort() }, TIMEOUT_MS_HIGHER) const response = await fetch(`${API_URL}/waste/update-waste-cover-photo`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: user.id, waste_id: wasteId, cover_photo }) }); const data = await response.json(); return data; } catch (error) { if (error.name === 'AbortError') { throw { message: "Failed to update cover photo, your connection timed out", name: "TimeOutError" }; } else { throw error; // Rethrow any other errors } } };
Save
waste