|
1 | 1 | <template> |
2 | | - <div class="container"> |
3 | | - <h2> |
4 | | - <img |
5 | | - src="https://www.gitbook.com/cdn-cgi/image/width=40,height=40,fit=contain,dpr=1,format=auto/https%3A%2F%2F2229349915-files.gitbook.io%2F~%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fspaces%252F-MKQ7_I-c79Ln1c6Chop%252Favatar-1603563866478.png%3Fgeneration%3D1603563866686051%26alt%3Dmedia" |
6 | | - /> |
7 | | - Astronomy API - Demo |
8 | | - </h2> |
9 | | - |
10 | | - <div class="row"> |
11 | | - <div class="column column-25"> |
12 | | - <p> |
13 | | - Copy your App Id and the App Secret from the |
14 | | - <a href="https://astronomyapi.com/dashboard" target="_blank" |
15 | | - >Astronomy API console</a |
16 | | - > |
17 | | - paste below to see the samples in action. |
18 | | - </p> |
19 | | - <form> |
20 | | - <fieldset> |
21 | | - <label>App Id</label> |
22 | | - <input |
23 | | - v-model="store.appId" |
24 | | - @change="validateCredentials" |
25 | | - type="text" |
26 | | - /> |
27 | | - <label>App Secret</label> |
28 | | - <input |
29 | | - v-model="store.appSecret" |
30 | | - @change="validateCredentials" |
31 | | - type="password" |
32 | | - /> |
33 | | - </fieldset> |
34 | | - </form> |
35 | | - |
36 | | - <div v-bind:class="messageClass" v-if="status">{{ status }}</div> |
37 | | - |
38 | | - <p v-if="store.credentialsValid">Explore each endpoint below.</p> |
39 | | - |
40 | | - <ul v-if="store.credentialsValid"> |
41 | | - <li> |
42 | | - <router-link to="/positions">Planetary Positions</router-link> |
43 | | - </li> |
44 | | - <li><router-link to="/star-chart">Star Charts</router-link></li> |
45 | | - <li><router-link to="/moon-phase">Moon Phase</router-link></li> |
46 | | - <li><router-link to="/search">Search</router-link></li> |
47 | | - </ul> |
48 | | - </div> |
49 | | - </div> |
50 | | - <div class="column column-75"></div> |
51 | | - </div> |
| 2 | + <router-view></router-view> |
52 | 3 | </template> |
53 | 4 |
|
54 | 5 | <script> |
55 | 6 | import { store } from "./store.js"; |
| 7 | +import Home from "./components/Home.vue"; |
56 | 8 |
|
57 | 9 | export default { |
| 10 | + components: { |
| 11 | + Home: Home, |
| 12 | + }, |
58 | 13 | data() { |
59 | 14 | return { |
60 | 15 | store, |
61 | | - status: "", |
62 | | - messageClass: "", |
63 | 16 | }; |
64 | 17 | }, |
65 | | - methods: { |
66 | | - validateCredentials() { |
67 | | - if (!store.appId || !store.appSecret) { |
68 | | - return; |
69 | | - } |
70 | | -
|
71 | | - this.status = "Checking Credentials..."; |
72 | | - axios |
73 | | - .get(`${store.apiEndpoint}/api/v2/bodies`, { |
74 | | - headers: { |
75 | | - "X-Requested-With": "XMLHttpRequest", |
76 | | - Authorization: `Basic ${btoa(`${store.appId}:${store.appSecret}`)}`, |
77 | | - }, |
78 | | - }) |
79 | | - .then((response) => { |
80 | | - console.log(response); |
81 | | -
|
82 | | - this.status = "Credentials valid"; |
83 | | - this.messageClass = "success"; |
84 | | - this.store.credentialsValid = true; |
85 | | - }) |
86 | | - .catch((e) => { |
87 | | - console.log(e); |
88 | | -
|
89 | | - this.status = "Credential validation failed"; |
90 | | - this.messageClass = "error"; |
91 | | - }); |
92 | | - }, |
93 | | - }, |
94 | 18 | }; |
95 | 19 | </script> |
0 commit comments