Please have a look at this codepen: https://codepen.io/_lars_/pen/PoYZgQo
I took a example and found some documentation about request options, request | ArcGIS API for JavaScript 4.12
Is it possible to add basic auth header to my request in this way?
Lars,
This thread should help.
https://community.esri.com/thread/236136-how-to-use-a-key-in-an-esrirequest-call