async function genericUpdate()

in frontend/app/utils/master-api-service.ts [606:632]


async function genericUpdate<T>(
  deliverableId: string,
  assetId: string,
  apiPath: string,
  update: T
): Promise<T> {
  const { status, data } = await axios.put<ResponseWrapper<T>>(
    `${API_DELIVERABLE}/${deliverableId}/asset/${assetId}/${apiPath}`,
    update,
    {
      validateStatus: (status) => status == 200 || status == 409,
    }
  );

  switch (status) {
    case 200:
      return data.data;
    case 409:
      return Promise.reject(
        "There was a conflict, somebody else has updated in the meantime. Please reload and try again."
      );
    default:
      return Promise.reject(
        `Got an unknown response ${status} from the server`
      );
  }
}