Skip to content

Commit c2c75ee

Browse files
committed
First attempt to call orcid API
1 parent 328490f commit c2c75ee

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
@@ -146,6 +146,7 @@
146146
</template>
147147

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

0 commit comments

Comments
 (0)