I created a "protocolla" function. The first time I call it, the promise is resolved. The second time I call it, however, the promise remains hanging.
I added some test variables to store the references to the "resolve" and "reject" functions and a couple of console logs that log "true" on the first execution and "false" on the second execution. I don't understand why it doesn't work the second time and I don't know how to fix it. Thank you.
let myReject, myResolve;
export const protocolla = (protocollaCommand: ProtocollaCommand): Promise<string> => {
    const operation = new Promise<string>((resolve, reject) => {
        myReject = reject
        myPromise = promise
        authOperation(token => {
            const requestOptions = {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': 'Bearer ' + token
                },
                body: JSON.stringify(protocollaCommand)
            };
            return fetch(baseUrl + "/api/protocollaMail", requestOptions);
        }, (res: Response) => {
            console.log('[JOR] reject', myReject === reject)
            console.log('[JOR] resolve', myResolve === resolve)
            if (!res.ok) {
                reject(res);
            } else {
                res.text()
                    .then(resolve)
                    .catch(reject)
            }
        }).catch(reject);
    })
    return operation
}
