Skip to content

Commit f8cb873

Browse files
committed
✨ update content type for header
1 parent 8eda361 commit f8cb873

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/App.vue

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,15 @@ export default {
406406
}
407407
408408
if (this.http_method != "") {
409-
curl_command_string = curl_command_string + " -X" + this.http_method;
409+
curl_command_string =
410+
curl_command_string + " --location --request " + this.http_method;
410411
}
411412
412413
if (this.is_application_json) {
413-
curl_command_string =
414-
curl_command_string + ' -H "Content-type: application/json"';
414+
if (this.body_type == "json") {
415+
curl_command_string =
416+
curl_command_string + ' --header "Content-type: application/json"';
417+
}
415418
}
416419
417420
if (this.custom_headers.length > 0) {
@@ -423,7 +426,7 @@ export default {
423426
) {
424427
curl_command_string =
425428
curl_command_string +
426-
' -H "' +
429+
' --header "' +
427430
custom_headers[index].key +
428431
": " +
429432
custom_headers[index].value +
@@ -434,7 +437,8 @@ export default {
434437
435438
if (this.body_type == "json" && this.json_body != "") {
436439
let json_body = JSON.stringify(JSON.parse(this.json_body));
437-
curl_command_string = curl_command_string + " -d '" + json_body + "'";
440+
curl_command_string =
441+
curl_command_string + " --data-raw '" + json_body + "'";
438442
}
439443
440444
if (this.body_type == "form_urlencoded" && this.custom_fields != "") {
@@ -454,7 +458,11 @@ export default {
454458
}
455459
}
456460
457-
curl_command_string = curl_command_string + " -d '" + str + "'";
461+
curl_command_string =
462+
curl_command_string + " --data-urlencode '" + str + "'";
463+
curl_command_string =
464+
curl_command_string +
465+
' --header "Content-Type: application/x-www-form-urlencoded"';
458466
}
459467
460468
if (this.body_type == "form_data" && this.custom_fields != "") {
@@ -464,15 +472,16 @@ export default {
464472
this.custom_fields[index].value != ""
465473
) {
466474
let str =
467-
" -F '" +
475+
" --form '" +
468476
this.custom_fields[index].key +
469477
"=" +
470478
this.custom_fields[index].value +
471479
"' ";
472480
473-
console.log(str);
474-
475481
curl_command_string = curl_command_string + str;
482+
curl_command_string =
483+
curl_command_string +
484+
' --header "Content-Type: multipart/form-data"';
476485
}
477486
}
478487
}

0 commit comments

Comments
 (0)