@Singtaa: Please consider leaving a review on the Asset Store if you enjoy using OneJS. It really helps us a lot! And, I promise it'll take less time than debugging your last script.😊 Oh also, OneJS V2 is now out of preview!
Menu

UnityWebRequest Example

Under ScriptEngine's INTEROP section, make sure to set the Objects mapping for "uwr".

TS
// Javascript
var uwr = require("uwr") // This is the exposed UnityWebRequestUsage object

uwr.GetTextFromUri("https://www.google.com", (text) => {
    log(text)
})
CS
// C#
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

public class UnityWebRequestUsage : MonoBehaviour {
    public void GetTextFromUri(string uri, Action<string> callback) {
        StartCoroutine(GetText(uri, callback));
    }

    IEnumerator GetText(string uri, Action<string> callback) {
        using (UnityWebRequest request = UnityWebRequest.Get(uri)) {
            yield return request.Send();

            if (request.result == UnityWebRequest.Result.ConnectionError) { // Error
                callback(request.error);
            } else { // Success
                callback(request.downloadHandler.text);
            }
        }
    }
}