How to format HTTP API call in Javascript?

喜欢而已 提交于 2019-12-11 04:45:32

问题


I am currently following the etherpad documentation in regards to calling the HTTP API "getText"

How would the API call be structured given these parameters?

Pad content can be updated and retrieved through the API

getText(padID, [rev]) returns the text of a pad 

Example returns:

{code: 0, message:"ok", data: {text:"Welcome Text"}}
{code: 1, message:"padID does not exist", data: null}

回答1:


You'll need 2 parameters:

  1. apiKey
  2. padID

The apiKey can be retrieved from a text file named APIKEY.txt in the root of etherpad-lite.

The padID is in the format groupID$padID.

Putting it all together, you can query the pad's content using the following endpoint and payload:

http://pad.domain.com/api/1/getText?apikey=<apiKey>&padID=<padID>

Ex: http://pad.domain.com/api/1/getText?apikey=6b2d257663asddfe8c78f33f94d8e7290asdasd1dea820ea0c37cf42602ea5eef3c&padID=g.fcXsYTpiNlJMwX35$samplePad



来源:https://stackoverflow.com/questions/42731984/how-to-format-http-api-call-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!