From ab83831af7d890d16745fdff66ab2cc9c33f2afc Mon Sep 17 00:00:00 2001
From: Audrey Hamelers <hamelers@ebi.ac.uk>
Date: Tue, 19 Mar 2019 09:53:40 +0000
Subject: [PATCH] #455

---
 app/components/citation-search/PubMedSearch.jsx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/app/components/citation-search/PubMedSearch.jsx b/app/components/citation-search/PubMedSearch.jsx
index e711684d6..11b5b8690 100755
--- a/app/components/citation-search/PubMedSearch.jsx
+++ b/app/components/citation-search/PubMedSearch.jsx
@@ -204,16 +204,18 @@ class PubMedSearch extends React.Component {
   async onSelected(result, journal) {
     const inPMC = result.articleids.find(id => id.idtype === 'pmc')
     if (inPMC) {
+      this.setState({ loading: true })
       const obj = {
         inPMC: result.title,
         pmcid: inPMC.value,
+        loading: false,
       }
       const epmcURL = `https://www.ebi.ac.uk/europepmc/webservices/rest/search?query=SRC:MED%20EXT_ID:${
         result.uid
       }&resulttype=lite&format=json`
       const response = await fetch(epmcURL)
       const json = await response.json()
-      const epmc = json.resultList.result[0].inEPMC
+      const epmc = json.resultList.result[0] && json.resultList.result[0].inEPMC
       if (epmc === 'Y') {
         obj.inEPMC = true
       }
-- 
GitLab