Proxyman Documentation
Homepage
Pricing
Blog
Download
Search…
Overview
Changelog
License
License Manager
Command-line
Proxyman iOS
Proxyman for iOS
Debug on Devices
macOS
iOS Device
iOS Simulator
tvOS & watchOS
Android Device & Emulator
Firefox
Java VMs
Python
Ruby
React Native
Flutter
HTTP Clients
Docker
Atlantis
Atlantis for iOS
BASIC FEATURES
Proxyman Proxy Helper Tool
Request / Response Previewer
SSL Proxying
Import / Export
Content Filter
Multiple Tabs
Horizontal/Vertical/Window Layout
Copy as
Custom Previewer Tab
Custom Header Column
Regex (Regular Expression)
Filter JSON Response
Highlight by Color and Add Comment
Import / Export Settings
Multipart Form-Data Previewer
JSONPath
Customize Toolbar
ADVANCED FEATURES
Repeat
Edit & Repeat
Compose new Request
No Caching
Breakpoint
Breakpoint Templates
Map Local (File)
Map Local (Directory)
Map Remote
External Proxy
Save Session
Protobuf
WebSocket
Clear Session
Block List
Allow List
Charles Proxy Converter
Custom Certificates
GraphQL
Network Conditions
Multiple Filters
Publish to Gist
Reverse Proxy
Code Generator
Diff
Scripting
Scripting
async/await Request
Addons
Built-in JS Libraries
Write your own Addons
Snippet Code
Environment Variables
Troubleshooting
Proxyman does not work with VPN apps
My Remote Devices (iOS/Android) could not connect to Proxyman?
SSL Error from HTTPS Request/Response
I could not see any requests from my localhost server
*.local requests do not appear on Proxyman
I couldn't see any traffics on Proxyman
I couldn't see any requests from 3rd-party network libraries
[Breakpoint] Modify Request/Response by Raw Message
Could not change Proxyman App Icons
Lost data after updating Proxyman app?
Powered By
GitBook
async/await Request
1. What's it?
From Proxyman 3.5.0, you can use
async / await
to make an HTTP/HTTPS call for retrieving external resources inside your Script.
Sample: POST Request with JSON Body
1
async
function
onResponse
(
context
,
url
,
request
,
response
)
{
2
// Define JSON Body and Header
3
// Make sure "Content-Type" is "application/json"
4
var
param
=
{
5
body
:
{
6
"user"
:
{
7
"name"
:
"Proxyman"
8
}
9
},
10
headers
:
{
11
"Content-Type"
:
"application/json"
12
}
13
}
14
​
15
// POST request with await
16
var
output
=
await
$http
.
post
(
"https://httpbin.org/post"
,
param
);
17
18
// Get Status Code
19
console
.
log
(
output
.
statusCode
);
20
21
// Get body
22
console
.
log
(
output
.
body
)
23
24
// Get header
25
console
.
log
(
output
.
headers
)
26
27
// Done
28
return
response
;
29
}
Copied!
2. How to use it?
Method
1
var
output
=
await
$http
.
get
(
"https://httpbin.org/anything"
);
2
var
output
=
await
$http
.
post
(
"https://httpbin.org/anything"
);
3
var
output
=
await
$http
.
put
(
"https://httpbin.org/anything"
);
4
var
output
=
await
$http
.
update
(
"https://httpbin.org/anything"
);
5
var
output
=
await
$http
.
delete
(
"https://httpbin.org/anything"
);
Copied!
Output format
1
var
output
=
await
$http
.
get
(
"https://httpbin.org/anything"
);
2
console
.
log
(
output
)
3
​
4
// print
5
{
6
"statusCode"
:
<
Int
>
,
7
"headers"
:
<
Object
>
,
8
"body"
:
<
Object
>
9
}
Copied!
Sample Code
​
GET Request with Query
​
​
POST Request with JSON Body
​
​
POST Request with application/x-www-form-urlencoded body
​
​
PUT / PATCH / DELETE Request
​
Please checkout the
HTTP Snippet code
for more sample code.
3. Notes
Make sure you defined the
async
function on
onRequest()
and
onResponse()
:
1
async
function
onRequest
(
context
,
url
,
request
)
{
2
var
output
=
await
$http
.
get
(
"https://httpbin.org/get"
);
3
return
request
;
4
}
5
​
6
async
function
onResponse
(
context
,
url
,
request
,
response
)
{
7
var
output
=
await
$http
.
get
(
"https://httpbin.org/get"
);
8
return
response
;
9
}
Copied!
Request Timeout is 10 seconds.
The inline HTTP Request doesn't go through the Proxyman Proxy, so it isn't affected by other debugging tools.
Use can use
await $http.get()
on both
onRequest()
and
onResponse()
Make sure the Body type is matched with the Content-Type header.
JSON Body with application/json
1
var
param
=
{
2
body
:
{
3
"name"
:
"Proxyman"
,
4
},
5
headers
:
{
6
"Content-Type"
:
"application/json"
7
}
8
}
Copied!
Encoded form Body with application/x-www-form-urlencoded
1
var
param
=
{
2
body
:
{
3
"key1"
:
"value1"
,
4
"key2"
:
"value2"
5
},
6
headers
:
{
7
"Content-Type"
:
"application/x-www-form-urlencoded"
8
}
9
}
Copied!
Scripting - Previous
Scripting
Next - Scripting
Addons
Last modified
11d ago
Copy link
Contents
1. What's it?
2. How to use it?
3. Notes