Skip to content

6-server.js has 7 copy-pasted methods with identical boilerplate Description #310

@avinxshKD

Description

@avinxshKD

all 7 methods in 6-server.js (build/debug/run/clear/stop/destroy/library) are literlly copy-paste with different URLs:

const toastId = toast.info('LOADING.......');
dispatcher({ type: T.SET_LOGS, payload: false });
Axios.post(url)
  .then(res => {
    toast.success(res.data['message']);
    dispatcher({ type: T.SET_FUNCTIONS, payload: {...} });
    toast.dismiss(toastId);
  })
  .catch(err => {
    toast.error(err.response?.data?.message || err.message);
    toast.dismiss(toastId);
  });
if (this.serverID); // ???

Fix one bug, gotta manually fix 6 more, already caused issues (see #297)

fix can be, Extract shared helper like _serverAction(method, url, successPayload). Refactor all methods to use it. Kill the useless if (this.serverID);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions