Skip to content

Is there a way to call an API only once to obtain external IDs for multiple files before upload? #708

Answered by datta202
datta202 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @yoavniran, I managed to fix this problem by using withBatchStartUpdate and react hooks

const BatchOperation = withBatchStartUpdate(
  (props: WithRequestPreSendUpdateWrappedProps) => {
    const allExternalIds = getAllExternalIds(externalIds);
    const { updateRequest, requestData } = props;
    const [loading, setLoading] = useState(false);

    const onUpload = useCallback(() => {
      if (requestData && updateRequest && requestData.options.destination) {
        updateRequest({
          items: requestData.items,
        });
      }
    }, [requestData, updateRequest, allExternalIds]);

    useEffect(() => {
      if (!requestData?.options || !requestData?.items) {
        return;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@datta202
Comment options

Answer selected by datta202
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants