I am using svelte/sapper with express.
I have an api in routes/billing/index.js
It needs to fetch data from customers/[customernumber]/detections.js
My question is how to fetch data from internal apis with in the routes folder using relative URLs
async function getDataFromGateway(customerNumber) {
if (typeof fetch !== 'function') {
global.fetch = require('node-fetch')
}
const data = await fetch(`http://localhost:19052/customers/${customerNumber}/detections`)
.then(res => res.json())
.catch(error => {
console.log(error)
return error
}
)
return data
}
Is there a way to do this using relative url
this.fetch
outside<script context="module">
, in a javaScript file – Golter