|
170 | 170 | </template> |
171 | 171 |
|
172 | 172 | <script lang="ts"> |
| 173 | +import axios from 'axios' |
173 | 174 | import { byError, emailQueries, orcidQueries } from 'src/error-filtering' |
174 | 175 | import { computed, defineComponent, onUpdated } from 'vue' |
175 | 176 | import SchemaGuideLink from 'src/components/SchemaGuideLink.vue' |
@@ -219,8 +220,29 @@ export default defineComponent({ |
219 | 220 | }) |
220 | 221 | const { errors } = useValidation() |
221 | 222 | const orcidErrors = computed(() => { |
222 | | - return orcidQueries(props.index) |
| 223 | + const orcidErrors = orcidQueries(props.index) |
223 | 224 | .filter(byError(errors.value)) |
| 225 | + if (orcidErrors.length === 0) { |
| 226 | + // If a valid orcid is found, look for data in the orcid API (maybe only if we do not have data already) |
| 227 | + const orcid = '0000-0001-8555-849X' // This should come from props.orcid |
| 228 | + const orcidEndpoint = 'https://pub.sandbox.orcid.org/v3.0/expanded-search/?q=orcid:' + orcid + '&rows=1' |
| 229 | + axios.get(orcidEndpoint, |
| 230 | + { |
| 231 | + data: {}, |
| 232 | + headers: { |
| 233 | + 'accept': 'application/vnd.orcid+json' |
| 234 | + } |
| 235 | + }).then(resp => { |
| 236 | + console.log('These values should be injected in the right places') |
| 237 | + console.log('email : ' + resp.data['expanded-result'][0]['email'][0]) |
| 238 | + console.log('last-name : ' + resp.data['expanded-result'][0]['family-names']) |
| 239 | + console.log('first-name: ' + resp.data['expanded-result'][0]['given-names']) |
| 240 | + console.log('Institution: ' + resp.data['expanded-result'][0]['institution-name']) |
| 241 | + console.log('Orcid : ' + resp.data['expanded-result'][0]['orcid-id']) |
| 242 | + |
| 243 | + }) |
| 244 | + } |
| 245 | + return orcidErrors |
224 | 246 | .map(query => query.replace.message) |
225 | 247 | }) |
226 | 248 | const emailErrors = computed(() => { |
|
0 commit comments