How to use fetch on client script?

How to use fetch on client script?

Not sure the correct syntax to use fetch within the client script when adding a token value. And then also saving that value to a variable to be used. Would someone be able to give me an example?


What I thought it may look like is:


{
headers: { Authentication: 'Bearer {'access token' }
})

      .then(response => response.json())     
      .then(data => log(data))

ZDK.Page.getForm().setValues({
EstimatedCost: api_key?
})