Skip to content

Commit ba28c53

Browse files
committed
First attempt to call orcid API
1 parent f3f1bca commit ba28c53

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
@@ -25,6 +25,7 @@
2525
"@quasar/extras": "^1.0.0",
2626
"ajv": "^8.6.2",
2727
"ajv-formats": "^2.1.1",
28+
"axios": "^0.27.2",
2829
"core-js": "^3.6.5",
2930
"deep-filter": "^1.0.2",
3031
"js-yaml": "^3.14.1",

src/components/AuthorCardEditing.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
</template>
146146

147147
<script lang="ts">
148+
import axios from 'axios'
148149
import { byError, emailQueries, orcidQueries } from 'src/error-filtering'
149150
import { computed, defineComponent } from 'vue'
150151
import InfoDialog from 'components/InfoDialog.vue'
@@ -192,8 +193,29 @@ export default defineComponent({
192193
setup (props) {
193194
const { errors } = useValidation()
194195
const orcidErrors = computed(() => {
195-
return orcidQueries(props.index)
196+
const orcidErrors = orcidQueries(props.index)
196197
.filter(byError(errors.value))
198+
if (orcidErrors.length === 0) {
199+
// If a valid orcid is found, look for data in the orcid API (maybe only if we do not have data already)
200+
const orcid = '0000-0001-8555-849X' // This should come from props.orcid
201+
const orcidEndpoint = 'https://pub.sandbox.orcid.org/v3.0/expanded-search/?q=orcid:' + orcid + '&rows=1'
202+
axios.get(orcidEndpoint,
203+
{
204+
data: {},
205+
headers: {
206+
'accept': 'application/vnd.orcid+json'
207+
}
208+
}).then(resp => {
209+
console.log('These values should be injected in the right places')
210+
console.log('email : ' + resp.data['expanded-result'][0]['email'][0])
211+
console.log('last-name : ' + resp.data['expanded-result'][0]['family-names'])
212+
console.log('first-name: ' + resp.data['expanded-result'][0]['given-names'])
213+
console.log('Institution: ' + resp.data['expanded-result'][0]['institution-name'])
214+
console.log('Orcid : ' + resp.data['expanded-result'][0]['orcid-id'])
215+
216+
})
217+
}
218+
return orcidErrors
197219
.map(query => query.replace.message)
198220
})
199221
const emailErrors = computed(() => {

0 commit comments

Comments
 (0)