Skip to content

Commit d5ea419

Browse files
committed
First attempt to call orcid API
1 parent ee4d5a4 commit d5ea419

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@quasar/extras": "^1.0.0",
2424
"ajv": "^8.6.2",
2525
"ajv-formats": "^2.1.1",
26+
"axios": "^0.27.2",
2627
"core-js": "^3.6.5",
2728
"deep-filter": "^1.0.2",
2829
"js-yaml": "^3.14.1",

src/components/AuthorCardEditing.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
</template>
171171

172172
<script lang="ts">
173+
import axios from 'axios'
173174
import { byError, emailQueries, orcidQueries } from 'src/error-filtering'
174175
import { computed, defineComponent, onUpdated } from 'vue'
175176
import SchemaGuideLink from 'src/components/SchemaGuideLink.vue'
@@ -219,8 +220,29 @@ export default defineComponent({
219220
})
220221
const { errors } = useValidation()
221222
const orcidErrors = computed(() => {
222-
return orcidQueries(props.index)
223+
const orcidErrors = orcidQueries(props.index)
223224
.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
224246
.map(query => query.replace.message)
225247
})
226248
const emailErrors = computed(() => {

0 commit comments

Comments
 (0)