From 122782f244d4259380d86cf557c001d98bfba672 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Kalloor Biju Date: Mon, 25 Nov 2019 19:19:21 +0000 Subject: [PATCH] Added headers field to state and added mutations to handle header list updates --- store/mutations.js | 16 ++++++++++++++++ store/state.js | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/store/mutations.js b/store/mutations.js index 1d3339c16..00e9590ee 100644 --- a/store/mutations.js +++ b/store/mutations.js @@ -7,6 +7,22 @@ export default { state.gql[object.attribute] = object.value; }, + addGQLHeader(state, object) { + state.gql.headers.push(object); + }, + + removeGQLHeader(state, index) { + state.gql.headers.splice(index, 1); + }, + + setGQLHeaderKey(state, object) { + state.gql.headers[object.index].key = object.value; + }, + + setGQLHeaderValue(state, object) { + state.gql.headers[object.index].value = object.value; + }, + addHeaders(state, value) { state.request.headers.push(value); }, diff --git a/store/state.js b/store/state.js index a4f7df544..99cc7900b 100644 --- a/store/state.js +++ b/store/state.js @@ -18,6 +18,7 @@ export default () => ({ contentType: '', }, gql: { - url: 'https://rickandmortyapi.com/graphql' + url: 'https://rickandmortyapi.com/graphql', + headers: [] } });