You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importaxiosfrom"axios";/* description: this function for callback api endpoint contains GET,POST,PUT, DELETE requests via axios package params: id , data - getOne method need only id params - getAll method no need any param - create method need only data param - updateByID method need both id and data params - update method need only data param - delete method also need only id param return: getOne, getAll, updateByID, update, delete*/exportdefault{endpoint(url){url="route.apiBase"+url;//concat base url and url with base api endpointreturn{getOne: (id)=>axios.get(url+`/${id}`),//id_urlgetAll: ()=>axios.get(url),create: (data)=>axios.post(url,data),//url, dataupdateByID: (id,data)=>axios.put(url+`/${id}`,data),//url, dataupdate: (data)=>axios.put(url,data),// without iddelete: (id)=>axios.delete(url+`/${id}`),}},}
In this file apiRoute contains api route where define all api endpoint and localRoute contains local traverse route which responsible for traverse from react app
api.endpoint(url).getAll()api.endpoint(url).getOne({id})api.endpoint(url).create(data)api.endpoint(url).update({ id },data)api.endpoint(url).delete({ id })