Reputation: 14399
In this SO post, shows how to add a simple config to a Vue app,
The top answer uses the following JS code.
fetch(process.env.BASE_URL + "config.json")
.then((json) => {
json().then((config) => {
Vue.prototype.$config = config
new Vue({
router,
store,
render: (h) => h(App)
}).$mount("#app")
})
})
which I put in my TS code, and get the following error.
ERROR in D:/TFS/StudentPortal4Vue/clientapp/src/main.ts(44,13): 44:13 This expression is not callable. Type 'Response' has no call signatures. 42 | .then((json) => 43 | {
44 | json().then((config) => | ^ 45 | { 46 | Vue.prototype.$config = config; 47 | new Vue({ Version: typescript 4.3.2
It's obvious to me that I have a type problem, but I'm stumped as to how to fix it.
(Super new at ts, and old but noobish at JS & Vue)
Upvotes: 0
Views: 32
Reputation: 37863
There is an error in the code ...should look like this:
fetch(process.env.BASE_URL + "config.json")
.then((response) => response.json())
.then((config) => {
Vue.prototype.$config = config
new Vue({
router,
store,
render: (h) => h(App)
}).$mount("#app")
})
Upvotes: 2