From 4f19bd9a387f7ecf8ffaf94e241e25770f144cfd Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Tue, 17 Nov 2020 02:03:34 +0100 Subject: [PATCH] Clean up directRequestHandler --- src/serviceproviders.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/serviceproviders.js b/src/serviceproviders.js index 00d66fb..fdcc3ae 100644 --- a/src/serviceproviders.js +++ b/src/serviceproviders.js @@ -66,17 +66,16 @@ const match = (uri, opts) => { } const directRequestHandler = async (spData, opts) => { - const res = await req( - spData.proof.fetch ? spData.proof.fetch : spData.proof.uri, - null, - { Accept: 'application/json' } - ) + const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri + let res switch (spData.proof.format) { case 'json': + res = await req(url, null, { Accept: 'application/json' }) return await res.json() break case 'text': + res = await req(url) return await res.text() break default: