Newer
Older
vue-demo / vue-client / static / js / student-list.js
Mark George on 27 Aug 2021 661 bytes Add project
/* global Vue, axios */

var studentListApi = `//localhost:8080/api/students`;

const app = Vue.createApp({

	data() {
		return {
			students: {}
		};
	},

	mounted() {

		axios.get(studentListApi)
			.then(response => {
				this.students = response.data;
			})
			.catch(error => {
				console.error(error);
				alert("An error occured - check the console for details.");
			});

	},

	methods: {
		view(selectedStudent) {
			sessionStorage.setItem('selectedStudent', JSON.stringify(selectedStudent));
			window.location = 'view.html';
		}
	}

});

import { PageHeader } from './pageheader.js';
app.component('pageheader', PageHeader);

app.mount('#content');