Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function Api ({ baseUrl }) {
// We append this to requests for presets and map styles, in order to override
// the local static server cache whenever the app is restarted. NB. sprite,
// font, and map tile requests might still be cached, only changes in the map
// style will be cache-busted.
const startupTime = Date.now()
const req = ky.extend({
prefixUrl: baseUrl,
// No timeout because indexing after first sync takes a long time, which mean
// requests to the server take a long time
timeout: false,
headers: {
'cache-control': 'no-cache',
pragma: 'no-cache'
}
})
function logRequest (prefix, promise) {
const start = Date.now()
promise
.then(data => {
logger.log(prefix, Date.now() - start + 'ms')
})