[GH-ISSUE #269] Generated code is incorrect #92

Closed
opened 2026-03-16 13:21:17 +03:00 by kerem · 2 comments
Owner

Originally created by @reefqi037 on GitHub (Nov 6, 2019).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/269

Describe the bug
There are a few bugs in the generated code for each request type (JavaScript XHR, Fetch, cURL):

XHR

  • Value of username, password, and headers are not being enclosed in quotes
  • Bearer token header is set incorrectly; 'Bearer ' + <token>

Fetch

  • Value of final header is not properly closed with quotes; "headerKey": "headerValue
  • Authorization token header is not properly closed with quotes;
    "Authorization": "Basic <value>,
    "Authorization": "Bearer Token <token>,
  • Bearer token header is set incorrectly; "Bearer Token <token>"
  • Generated code is not being enclosed properly i.e. copy and run the code will produce SyntaxError

cURL

  • Bearer token header is set incorrectly; 'Bearer Token <value>'

To Reproduce

  1. Set Authentication and add a few Headers
  2. Generate code for each request type

Expected behavior

XHR

  • Value of username, password, and headers are properly enclosed with quotes
  • Bearer token header is set correctly; 'Bearer <token>'

Fetch

  • Value of final header is properly closed with quotes; "headerKey": "headerValue"
  • Authorization token header is properly closed with quotes;
    "Authorization": "Basic <value>",
    "Authorization": "Bearer <token>",
  • Bearer token header is set correctly; "Bearer <token>" (without the Token)
  • Generated code is being enclosed properly

cURL

  • Bearer token header is set correctly; 'Bearer <value>' (without the Token)

Screenshots

XHR
xhr_basic_before
xhr_bearer_before

Fetch
fetch_bearer_before

cURL
curl_bearer_before

Originally created by @reefqi037 on GitHub (Nov 6, 2019). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/269 **Describe the bug** There are a few bugs in the generated code for each request type (JavaScript XHR, Fetch, cURL): XHR - Value of username, password, and headers are not being enclosed in quotes - Bearer token header is set incorrectly; ```'Bearer ' + <token>``` Fetch - Value of final header is not properly closed with quotes; ```"headerKey": "headerValue``` - Authorization token header is not properly closed with quotes; ```"Authorization": "Basic <value>,``` ```"Authorization": "Bearer Token <token>,``` - Bearer token header is set incorrectly; ```"Bearer Token <token>"``` - Generated code is not being enclosed properly i.e. copy and run the code will produce SyntaxError cURL - Bearer token header is set incorrectly; ```'Bearer Token <value>'``` **To Reproduce** 1. Set ```Authentication``` and add a few ```Headers``` 2. Generate code for each request type **Expected behavior** XHR - Value of username, password, and headers are properly enclosed with quotes - Bearer token header is set correctly; ```'Bearer <token>'``` Fetch - Value of final header is properly closed with quotes; ```"headerKey": "headerValue"``` - Authorization token header is properly closed with quotes; ```"Authorization": "Basic <value>",``` ```"Authorization": "Bearer <token>",``` - Bearer token header is set correctly; ```"Bearer <token>"``` (without the **Token**) - Generated code is being enclosed properly cURL - Bearer token header is set correctly; ```'Bearer <value>'``` (without the **Token**) **Screenshots** XHR ![xhr_basic_before](https://user-images.githubusercontent.com/44827833/68275688-bdb11f80-00af-11ea-843a-4d4afedf9f09.PNG) ![xhr_bearer_before](https://user-images.githubusercontent.com/44827833/68275714-cc97d200-00af-11ea-9248-f44e4b3a0880.PNG) Fetch ![fetch_bearer_before](https://user-images.githubusercontent.com/44827833/68275835-0a94f600-00b0-11ea-8b56-3feadfac1b93.PNG) cURL ![curl_bearer_before](https://user-images.githubusercontent.com/44827833/68275923-197ba880-00b0-11ea-8621-24a8399d609c.PNG)
kerem closed this issue 2026-03-16 13:21:23 +03:00
Author
Owner

@liyasthomas commented on GitHub (Nov 6, 2019):

Thanks for noticing those issues! We're on it.

<!-- gh-comment-id:550178656 --> @liyasthomas commented on GitHub (Nov 6, 2019): Thanks for noticing those issues! We're on it.
Author
Owner

@reefqi037 commented on GitHub (Nov 6, 2019):

I've made the fixes btw. Making the PR now.

<!-- gh-comment-id:550178907 --> @reefqi037 commented on GitHub (Nov 6, 2019): I've made the fixes btw. Making the PR now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#92
No description provided.