Neutralino.net
Neutralino.net exposes methods for communicating with HTTP/HTTPS network resources. This API is implemented at the framework-level (C++),
so webview CORS won't block any request made from these methods.
net.request(url, options)
Sends an HTTP/HTTPs request and retrive its output body and other response details. Throws NE_NW_SSLCONN, NE_NW_SSLLOAD, NE_NW_SSLVERI, NE_NW_SSLHOST, or,
NE_NW_HTTPERR based on the underlying network errors.
Parameters
urlString: An HTTP/HTTPS URL.methodString (optional): HTTP method, i.e.,GET,POST,PATCH, etc. Default isGET.
Options
contentTypeString: Content type, i.e.,text/plain. Default isapplication/json.timeoutNumber: Maximum timeout.paramsObject: Key-value pairs of parameters.headersObject: Key-value pairs of request headers.authObject: authentication credentials.usernameString: username.passwordString: password.
bodyString: Message body.allowRedirectsBoolean: Following location redirects automatically. Default isfalse.encodePathBoolean: Encode URL automatically. Default istrue.keepAliveBoolean: Enables persistent TCP connections. Default isfalse.
Return Object (awaited):
statusNumber: Status code.statusTextString: Status description.bodyString: Message body.headersObject: Key-value pairs of response headers.cookiesString: Response cookies.contentTypeString: Response content type.locationString: Redirect location. This is usually set if the request'sallowRedirectsoption is set tofalse.versionString: The server's HTTP version.
let response = await Neutralino.net.request('https://example.com', { method: 'PUT' });
console.log(response.status);
console.log(response.body);
net.get(url, options)
Calls net.request(url, 'GET', options) to make a GET request. All input parameters, options, thrown errors,
and the response is identical to net.request().
net.post(url, options)
Calls net.request(url, 'POST', options) to make a POST request. All input parameters, options, thrown errors,
and the response is identical to net.request().
net.put(url, options)
Calls net.request(url, 'PUT', options) to make a PUT request. All input parameters, options, thrown errors,
and the response is identical to net.request().
net.patch(url, options)
Calls net.request(url, 'PATCH', options) to make a PATCH request. All input parameters, options, thrown errors,
and the response is identical to net.request().
net.delete(url, options)
Calls net.request(url, 'DELETE', options) to make a DELETE request. All input parameters, options, thrown errors,
and the response is identical to net.request().
net.options(url, options)
Calls net.request(url, 'OPTIONS', options) to make an OPTIONS request. All input parameters, options, thrown errors,
and the response is identical to net.request().
net.head(url, options)
Calls net.request(url, 'HEAD', options) to make a HEAD request. All input parameters, options, thrown errors,
and the response is identical to net.request().