[GH-ISSUE #2205] [feature]: Function to send request from pre-request script #752

Closed
opened 2026-03-16 17:01:06 +03:00 by kerem · 16 comments
Owner

Originally created by @greg-vstorm on GitHub (Mar 25, 2022).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/2205

Is there an existing issue for this?

  • I have searched the existing issues

Summary

Postman provides method sendRequest to make AJAX request from pre-request script. For example:

pm.sendRequest({
    url: 'http://example.localhost/sanctum/csrf-cookie',
    method: 'GET'
}, function (error, response, {cookies}) {
    if (!error) {
        pm.environment.set('xsrf-token', cookies.get('XSRF-TOKEN'))
    }
})

This feature is useful when you need to get for example xsrf-token,

Why should this be worked on?

Allow testing API's build with Laravel Scout to get xsrf-token. I think it's much more use cases than this one.

Originally created by @greg-vstorm on GitHub (Mar 25, 2022). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/2205 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Summary Postman provides method `sendRequest` to make AJAX request from pre-request script. For example: ```js pm.sendRequest({ url: 'http://example.localhost/sanctum/csrf-cookie', method: 'GET' }, function (error, response, {cookies}) { if (!error) { pm.environment.set('xsrf-token', cookies.get('XSRF-TOKEN')) } }) ``` This feature is useful when you need to get for example xsrf-token, ### Why should this be worked on? Allow testing API's build with Laravel Scout to get xsrf-token. I think it's much more use cases than this one.
kerem 2026-03-16 17:01:06 +03:00
  • closed this issue
  • added the
    feature
    label
Author
Owner

@AndrewBastin commented on GitHub (Mar 27, 2022):

Thank you for reporting.

We will consider this during the planned revamp of the Scripting System.

<!-- gh-comment-id:1079939125 --> @AndrewBastin commented on GitHub (Mar 27, 2022): Thank you for reporting. We will consider this during the planned revamp of the Scripting System.
Author
Owner

@wakeupmh commented on GitHub (Mar 31, 2022):

Send request is a missing great feature, please, can you priorize this? 🥺
@AndrewBastin

<!-- gh-comment-id:1084730945 --> @wakeupmh commented on GitHub (Mar 31, 2022): Send request is a missing great feature, please, can you priorize this? 🥺 @AndrewBastin
Author
Owner

@AndrewBastin commented on GitHub (Mar 31, 2022):

Yup, I am working on a solution for this, stay tuned!

<!-- gh-comment-id:1085021876 --> @AndrewBastin commented on GitHub (Mar 31, 2022): Yup, I am working on a solution for this, stay tuned!
Author
Owner

@987Nabil commented on GitHub (Aug 5, 2022):

@AndrewBastin Any news on this?

<!-- gh-comment-id:1206094378 --> @987Nabil commented on GitHub (Aug 5, 2022): @AndrewBastin Any news on this?
Author
Owner

@lslavuj commented on GitHub (Oct 19, 2022):

@AndrewBastin Any news?

<!-- gh-comment-id:1284526958 --> @lslavuj commented on GitHub (Oct 19, 2022): @AndrewBastin Any news?
Author
Owner

@AndrewBastin commented on GitHub (Oct 22, 2022):

Please discuss about this in the RFC discussion #2292 for the scripting API revamp.

We are working on a scripting API revamp to support for more complex use cases.

<!-- gh-comment-id:1287803146 --> @AndrewBastin commented on GitHub (Oct 22, 2022): Please discuss about this in the RFC discussion #2292 for the scripting API revamp. We are working on a scripting API revamp to support for more complex use cases.
Author
Owner

@lathindu1 commented on GitHub (Feb 16, 2023):

Any update guys. can we get CSRF token in Pre-request scripts now ? We really need it's to test Laravel

<!-- gh-comment-id:1433503157 --> @lathindu1 commented on GitHub (Feb 16, 2023): Any update guys. can we get CSRF token in Pre-request scripts now ? We really need it's to test Laravel
Author
Owner

@laDanz commented on GitHub (Nov 7, 2023):

Still waiting for this, would really improve my user experience...
I guess it should not be closed, even if it is mentioned on #2292 ?
All other mentioned features on #2292 are not closed...

<!-- gh-comment-id:1798033200 --> @laDanz commented on GitHub (Nov 7, 2023): Still waiting for this, would really improve my user experience... I guess it should not be closed, even if it is mentioned on #2292 ? All other mentioned features on #2292 are not closed...
Author
Owner

@bforbis commented on GitHub (Nov 16, 2023):

Would like to add my +1 support for this feature, as it is making it difficult for me to migrate from Postman.

My Use Case: A pre-request script that handles creation of OAuth 2.0 client_credentials grant access token before the request, then stores both the access token and expiration in environment variables.

I have been using this in postman before Postman even added OAuth 2 support, and it's a great way to get around the lack of Hoppscotch support for OAuth 2.0 client_credentials grant (see https://github.com/hoppscotch/hoppscotch/issues/874)

It would be really great if these pre-request scripts could then be stored at the collection level and shared.

<!-- gh-comment-id:1815232591 --> @bforbis commented on GitHub (Nov 16, 2023): Would like to add my +1 support for this feature, as it is making it difficult for me to migrate from Postman. **My Use Case**: A pre-request script that handles creation of OAuth 2.0 client_credentials grant access token before the request, then stores both the access token and expiration in environment variables. I have been using this in postman before Postman even added OAuth 2 support, and it's a great way to get around the lack of Hoppscotch support for OAuth 2.0 client_credentials grant (see https://github.com/hoppscotch/hoppscotch/issues/874) It would be really great if these pre-request scripts could then be stored at the collection level and shared.
Author
Owner

@nandi95 commented on GitHub (Apr 25, 2024):

Why was this issue closed?

<!-- gh-comment-id:2076746411 --> @nandi95 commented on GitHub (Apr 25, 2024): Why was this issue closed?
Author
Owner

@andras-gyarmati commented on GitHub (Jun 10, 2024):

id also need this feature. please update us

<!-- gh-comment-id:2157724781 --> @andras-gyarmati commented on GitHub (Jun 10, 2024): id also need this feature. please update us
Author
Owner

@FarhanShares commented on GitHub (Aug 19, 2024):

Aug 19, 2024: Any updates? This is a much needed feature.

<!-- gh-comment-id:2297106539 --> @FarhanShares commented on GitHub (Aug 19, 2024): Aug 19, 2024: Any updates? This is a much needed feature.
Author
Owner

@dreamscached commented on GitHub (Feb 13, 2025):

Bumping, is that a thing yet?

<!-- gh-comment-id:2656652361 --> @dreamscached commented on GitHub (Feb 13, 2025): Bumping, is that a thing yet?
Author
Owner

@Nackophilz commented on GitHub (Jul 18, 2025):

Bump, 2025 still need this feature .. ^^

<!-- gh-comment-id:3088813611 --> @Nackophilz commented on GitHub (Jul 18, 2025): Bump, 2025 still need this feature .. ^^
Author
Owner

@laDanz commented on GitHub (Jul 30, 2025):

leaving hopscotch for bruno.

<!-- gh-comment-id:3137426874 --> @laDanz commented on GitHub (Jul 30, 2025): leaving hopscotch for bruno.
Author
Owner

@jamesgeorge007 commented on GitHub (Aug 4, 2025):

Hi, we have an updated RFC for the revamped scripting system that covers the above scope. We’d appreciate reviews and feedback directly on the RFC itself, so we can keep the discussion focused and productive.

<!-- gh-comment-id:3150090470 --> @jamesgeorge007 commented on GitHub (Aug 4, 2025): Hi, we have an [updated RFC](https://github.com/hoppscotch/hoppscotch/discussions/5221) for the revamped scripting system that covers the above scope. We’d appreciate reviews and feedback directly on the RFC itself, so we can keep the discussion focused and productive.
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#752
No description provided.