Fetch is adding local host and IP address of the Vue app in front of the url when I include a variable for a project ID in API request. If the projectId is hard coded the endpoint works. How do I eliminate the local part of the url?
I have tried to add the variable as ${projectId}
or be concatenation projectId
the result is the same. The url sent looks like
const projectId = ref('')
const uri = `"https://developer.api.autodesk.com/bim360/admin/v1/projects/b.${ projectId.value}/users"`
function getUsers() {
fetch
(uri, requestOptions)
.then(response => response.json())
.then((response) => {
res.value = response
})
.catch(error => console.log('error', error))
}
Looking in the network the url that is sent looks like this
Not a real projectID by the way. Thanks for any suggestions!
CodePudding user response:
It looks like you're using extra quotations (""). When you're using string interpolation you don't need to use quotations (""). Declare your URI like example given bellow.
const uri = `https://developer.api.autodesk.com/bim360/admin/v1/projects/b.${ projectId.value}/users`