I am looking to access a .json file through a link. When I enter the link to my json file in the browser, it prompts me for credentials (username and password) which I have. I want to include the credentials in the code so that I don't have to manually log in anymore, OR receive a request to input my credentials when the website is attempting to retrieve data from the json file.
If there are other methods to access the json file apart from using callApi, feel free to suggest them. :)
Here is the current code without authentication and with a local file:
<script>
import jsonData from '../../static/json/test.json'
export default {
name: 'dash',
data() {
return {
data: ''
}
},
mounted() {
this.fetchData()
},
methods: {
fetchData() {
this.callApi()
.then((responseData) => {
this.data = responseData;
})
},
callApi() {
return Promise.resolve(jsonData)
}
}
}
</script>