mirror of
https://github.com/longbridge/developers.git
synced 2026-09-19 03:34:09 +08:00
17 lines
693 B
Plaintext
17 lines
693 B
Plaintext
{{?data.bodyParameter.present}}const inputBody = '{{=data.bodyParameter.exampleValues.json}}';{{?}}
|
|
{{?data.allHeaders.length}}const headers = {
|
|
{{~data.allHeaders :p:index}} '{{=p.name}}':{{=p.exampleValues.json}}{{?index < data.allHeaders.length-1}},{{?}}
|
|
{{~}}};
|
|
{{?}}
|
|
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{{?}}
|
|
})
|
|
.then(function(res) {
|
|
return res.json();
|
|
}).then(function(body) {
|
|
console.log(body);
|
|
});
|