From 3693c89894081ede5a38880b508b2a446f923eb8 Mon Sep 17 00:00:00 2001 From: elblogbruno Date: Sat, 14 Sep 2024 16:37:43 +0200 Subject: [PATCH] Refactor: add authorization header to API request --- admin/src/components/Input/index.js | 7 ++++++- admin/src/index.js | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/admin/src/components/Input/index.js b/admin/src/components/Input/index.js index c39aab3..1e98532 100644 --- a/admin/src/components/Input/index.js +++ b/admin/src/components/Input/index.js @@ -75,7 +75,12 @@ const Tags = ({ return []; } try { - const res = await axios.get(attribute.options["apiUrl"]); + const token = attribute.options["apiToken"]; + const res = await axios.get(attribute.options["apiUrl"], { + headers: { + Authorization: `Bearer ${token}`, + }, + }); setSuggestions(res.data); } catch (err) { console.log(err); diff --git a/admin/src/index.js b/admin/src/index.js index cbef860..ed4deb5 100644 --- a/admin/src/index.js +++ b/admin/src/index.js @@ -38,6 +38,16 @@ export default { value: "", options: [], }, + { + intlLabel: { + id: "tagsinput.tags.section.apiUrl", + defaultMessage: "API Token", + }, + name: "options.apiToken", + type: "text", + value: "", + options: [], + }, ], }, ],