簡體   English   中英

如何在 WSO2 APIM 中的“腳本中介”javascript 語言中發送 http 請求?

[英]How to send http request in "script mediator" javascript language in WSO2 APIM?

我嘗試了“fetch”、“XMLHttpRequest”、“jquery”函數在腳本內聯調解器 wso2 發布者中發送 http 請求。 but in logs wso2 says "XMLHttpRequest" not defined and for jquery "$ not defined" and for "fetch" syntax error" Is there any way to send http request in script mediator of wso2 apim? this is jquey error.

[2022-08-25 15:53:25,508] ERROR - ScriptMediator {api:run:v1} The script engine returned an 
error executing the inlined js script function mediate
com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: 
ReferenceError: "$" is not defined. (<Unknown Source>#5) in <Unknown Source> at line number 5

我的調解員:

<script language="js" source="https://code.jquery.com/jquery-1.7.1.min.js">
<![CDATA[
print("before sent########################################");

$.get("http://run.mocky.io/v2/5185415ba171ea3a00704eed", function(data, status){
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

print("Data: DDDDDDDDDDDDDDDDD" + data + "\nStatus: " + status);
});

print("sent########################################");
]]>
</script>

請檢查問題的答案: Cannot send request in mediation synapse in wso2 apim

在這里也有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM