Vote count: 0 I'm currently developing a webapp in Vuejs. I created a Mixin that I can access globally which handles any request to my api: export default { data() { retu { apiURL: 'http://example.com/api', timeout: 10000, }; }, methods: { callAPI(method, url, body) { this.$http({ url: this.apiURL + url, method, body, timeout: this.timeout, }) .then((response) => response, (response) => { if (response.data.error) { this.error = response.data.error; } else { this.error = 'We can't coect to the server. Please try again in a few minutes.'; } retu response; }); // retu 'test'; }, }, }; Now, in some of my components I call the api function: const api_response = this.callAPI('POST', '/auth', crede...
ادامه مطلب