Node.js 正在提取Express中的查询参数?
我正在Node.JS中为AppleScript应用程序编写API。AppleScript应用程序以以下形式在shell脚本中运行Node.js 正在提取Express中的查询参数?,node.js,curl,express,request,applescript,Node.js,Curl,Express,Request,Applescript,我正在Node.JS中为AppleScript应用程序编写API。AppleScript应用程序以以下形式在shell脚本中运行curl: do shell script ("cd " & quoted form of myDir & " curl http://localhost:5000/server.properties?some-value=true&next-value=something%20else&[...] -O") 它旨在将名为server.
curl
:
do shell script ("cd " & quoted form of myDir & "
curl http://localhost:5000/server.properties?some-value=true&next-value=something%20else&[...] -O")
它旨在将名为server.properties
的文件下载到目录myDir
,其内容基于指定的参数,但由于某些原因,当Express收到请求时,在我运行console.log(res.originalUrl)
时,它仅显示此内容:
它将请求视为未指定任何其他参数。谁能告诉我我做错了什么,或者如何找出哪里出了问题
编辑这就是我运行shell脚本的方式。需要引用URL,以便
&
不会在shell脚本中充当运算符。我的解决方案如下:
do shell script ("cd " & quoted form of myDir & "
curl " & quoted form of (myUrl & myQuery) & " -O")
其中
myUrl
设置为”http://localhost:5000/server.properties“
和myQuery
设置为”?some value=true&next value=something%20other&[…]”
是否尝试在URL周围输出引号?&
在大多数shell中都是一个操作符,可能会破坏命令。哦!可能就是这样,让我检查一下。这似乎就是问题所在。我在AppleScript中使用了关键短语引用形式的
,所有内容都发送得非常好!做一个答案,我会加上正确的答案。是的,我知道。我打错了我的原始代码。
do shell script ("cd " & quoted form of myDir & "
curl " & quoted form of (myUrl & myQuery) & " -O")