'JavaScript in IntelliJ rest client
I have read most if not all of the documentation JetBrains provides about their HTTP Client and how to create requests using files with .http extension.
My problem is that I want to use a function in a different .js file inside one of the .http request files. The way they explain how this can be achieved is with this 1 liner "For external scripts, you need to enable it manually." The problem is they don't explain how you do the manual part. I did find that you have add any custom js code/library via Settings-> Languages and Frameworks -> JavaScript -> Libraries.
So my question is if anyone knows how to import custom JavaScript in a different location in a .http file? My JavaScript function is written in this manner:
export default function writeResponse(response, client) { ... }
Solution 1:[1]
For external scripts, you need to enable it manually
This quote from the docs is about enabling code assistance for external script, not about importing and exporting functions from scripts.
For your scenario, please try load(), for example:
### Import a function check() from a script new.js
GET http://example.org
> {%
load('/Users/YourPathToScript/scripts/new.js');
check();
%}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hérisson |
