Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
stfsy committed Jan 3, 2022
1 parent 2651a6f commit 3c5b3c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions templates/code_javascript.dot
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{{?data.bodyParameter.present}}const inputBody = '{{=data.bodyParameter.exampleValues.json}}';{{?}}{{?data.allHeaders.length}}const headers = {
{{?data.bodyParameter.present}}const body = {{=data.bodyParameter.exampleValues.json}}

{{?}}{{?data.allHeaders.length}}const headers = {
{{~data.allHeaders :p:index}} '{{=p.name}}':{{=p.exampleValues.json}}{{?index < data.allHeaders.length-1}},{{?}}
{{~}}};
{{~}}}
{{?}}
const response = await fetch('{{=data.url}}{{=data.requiredQueryString}}', {
method: '{{=data.methodUpper}}'{{?data.bodyParameter.present || data.allHeaders.length}},{{?}}{{?data.bodyParameter.present}} body: inputBody{{?}}{{? data.bodyParameter.present && data.allHeaders.length}},{{?}}{{?data.allHeaders.length}} headers: headers{{?}}
method: '{{=data.methodUpper}}'{{?data.bodyParameter.present || data.allHeaders.length}},{{?}}{{?data.bodyParameter.present}} body{{?}}{{? data.bodyParameter.present && data.allHeaders.length}},{{?}}{{?data.allHeaders.length}} headers{{?}}
})

const body = await response.json()

0 comments on commit 3c5b3c6

Please sign in to comment.