Typescript execute document.execCommand ('copy') after getting Http
I have a problem where I cannot execute document.execCommand ('copy') directly after a receive request (the request request is wrapped in a service that returns an Observable). I assume it is because the get request is an asynchronous call, so the event is no longer considered trusted.
I thought that I might wait for the service call ...
async getBearerToken(username: string) {
const token = await this._getTokenService.getToken('scopevar', username).first().toPromise();
this._clipboard.copy(token);
}
But it didn't work.
Note that the _clipboard service just creates the textbox, inserts the DOM and sets the text, and then calls document.execCommand - it works when called directly from one button click, without any other asynchronous calls. I suppose I somehow need to make sure that this call and the previous call are on the same thread.
My understanding is that the job should be to do this in 2 steps, get the text, set it to the text area, and then force the user to click again - I'd rather do it right though. (this is just an internal application to grab user test tokens for testing)
So how can I achieve this without a nasty workaround?
source to share
No one has answered this question yet
Check out similar questions: