I've used NSwag to generate a typescript API client, using Axios template, to be used in my vue frontend (I can add the generated client as well as the nswag config if needed).
Axios has been added as dependency:
"dependencies": {
"axios": "^0.19.0",
"core-js": "^2.6.5",
"vue": "^2.6.10",
"vue-router": "^3.0.3",
"vuelidate": "^0.7.4"
},
For now I've only tried to import a single client:
import usersClient from "@/api.ts";
When serving the frontend with npm run serve
I get following error (due to above import):
ERROR Failed to compile with 1 errors 11:51:19
error in ./src/api.ts
Module parse failed: Unexpected token (13:12)
You may need an appropriate loader to handle this file type.
|
| export class UsersClient {
> private instance: AxiosInstance;
| private baseUrl: string;
| protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
@ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/LoginDialogModal.vue?vue&type=script&lang=js& 69:0-35
@ ./src/components/LoginDialogModal.vue?vue&type=script&lang=js&
@ ./src/components/LoginDialogModal.vue
@ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&
@ ./src/App.vue?vue&type=script&lang=js&
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.1.110:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
Can someone put me in the right direction what the suggestion You may need an appropriate loader to handle this file type.
means?
I'm new to vue and not too proficient with the entire web stack, so I might miss something obvious to some.