123456789101112131415161718192021222324252627282930313233 |
- const xhr = new XMLHttpRequest();
- xhr.open('GET', '/appsmvc/testmvc.json', false);
- let data = [];
- xhr.onload = function () {
- if (xhr.status >= 200 && xhr.status < 300) {
- try {
- const json = JSON.parse(xhr.responseText);
-
- data = Object.entries(json).map(([key, value]) => {
- return { key, value };
- });
- } catch (error) {
- console.error('Failed to parse JSON');
- }
- } else {
- console.error('Failed to load JSON data');
- }
- };
- xhr.onerror = function () {
- console.error('Network error');
- };
- xhr.send();
- export default data;
|