@@ -27,9 +27,9 @@ async function query(form) {
2727 fetch ( QUERY_URL , {
2828 method : "POST" ,
2929 mode : "cors" ,
30- headers : new Headers ( {
30+ headers : {
3131 'Content-Type' : 'application/json; charset=utf-8'
32- } ) ,
32+ } ,
3333 body : JSON . stringify ( queryObj )
3434 } )
3535 . then ( response => {
@@ -58,9 +58,9 @@ async function importObj(form) {
5858 fetch ( UPDATE_URL , {
5959 method : 'PUT' ,
6060 body : JSON . stringify ( objForImport ) ,
61- headers : new Headers ( {
61+ headers : {
6262 'Content-Type' : 'application/json; charset=utf-8'
63- } )
63+ }
6464 } )
6565 . then ( response => {
6666 if ( ! response . ok ) { throw response }
@@ -105,9 +105,9 @@ async function update(form, objIn) {
105105 fetch ( UPDATE_URL , {
106106 method : 'PUT' ,
107107 body : JSON . stringify ( obj ) ,
108- headers : new Headers ( {
108+ headers : {
109109 'Content-Type' : 'application/json; charset=utf-8'
110- } )
110+ }
111111 } )
112112 . then ( response => {
113113 if ( response . ok ) { return response . json ( ) }
@@ -130,7 +130,7 @@ async function update(form, objIn) {
130130async function create ( form ) {
131131 let obj = form . getElementsByTagName ( "textarea" ) [ 0 ] . value
132132 try {
133- obj = JSON . parse ( obj )
133+ JSON . parse ( obj )
134134 } catch ( error ) {
135135 console . error ( "You did not provide valid JSON" )
136136 setMessage ( "You did not provide valid JSON" )
@@ -139,10 +139,10 @@ async function create(form) {
139139 }
140140 fetch ( CREATE_URL , {
141141 method : 'POST' ,
142- body : JSON . stringify ( obj ) ,
143- headers : new Headers ( {
142+ body : obj ,
143+ headers : {
144144 'Content-Type' : 'application/json; charset=utf-8'
145- } )
145+ }
146146 } )
147147 . then ( response => {
148148 if ( response . ok ) { return response . json ( ) }
@@ -166,9 +166,9 @@ async function deleteObj(form) {
166166 let url = form . getElementsByTagName ( "input" ) [ 0 ] . value
167167 fetch ( `${ DELETE_URL } /${ url . split ( 'id/' ) . pop ( ) } ` , {
168168 method : 'DELETE' ,
169- headers : new Headers ( {
169+ headers : {
170170 'Content-Type' : 'text/plain; charset=utf-8'
171- } )
171+ }
172172 } )
173173 . then ( response => {
174174 if ( response . status === 204 ) {
@@ -198,7 +198,7 @@ async function overwrite(form, objIn) {
198198 else {
199199 obj = form . getElementsByTagName ( "textarea" ) [ 0 ] . value
200200 try {
201- obj = JSON . parse ( obj )
201+ JSON . parse ( obj )
202202 }
203203 catch ( err ) {
204204 _customEvent ( "rerum-error" , "You did not provide valid JSON" , { } , err )
@@ -208,10 +208,10 @@ async function overwrite(form, objIn) {
208208 obj [ "@id" ] = uri
209209 fetch ( OVERWRITE_URL , {
210210 method : 'PUT' ,
211- body : JSON . stringify ( obj ) ,
212- headers : new Headers ( {
211+ body : obj ,
212+ headers : {
213213 'Content-Type' : 'application/json; charset=utf-8'
214- } )
214+ }
215215 } )
216216 . then ( response => {
217217 if ( response . ok ) { return response . json ( ) }
0 commit comments