Fix textMetadata query for results without fields

See #18

Change-Id: Ia96b1896c6c5ffb1dda814daa0449aa0560acefc
diff --git a/R/textMetadata.R b/R/textMetadata.R
index bc07be0..32d8d12 100644
--- a/R/textMetadata.R
+++ b/R/textMetadata.R
@@ -43,7 +43,7 @@
     if(is.null(res)) {
       res <- tibble(errors="API request failed")
     } else {
-      if ("document" %in% names(res) & "fields" %in% names(res$document)) {
+      if ("document" %in% names(res) & "fields" %in% names(res$document) && length(res$document$fields) > 0) {
         res <- as_tibble(res$document$fields) %>%
           select(key, value) %>%
           tidyr::pivot_wider(names_from = key, values_from = value, names_repair = "unique") %>%