MCPcopy
hub / github.com/kenberkeley/react-demo / fetch

Method fetch

src/services/msgService.js:14–24  ·  view source on GitHub ↗

* 取 msg(命名为 fetch 而非 get 主要是因为是远程操作) * @param {String} options.author 作者名 * @param {Number} options.pageIdx 目标页码(默认是第 1 页) * @param {Number} options.quantity 单页请求 msg 的数量(默认每页显示 10 条) * @param {Number} options.msgId * @return {Promise}

({ author = '', pageIdx = 1, quantity = 10, msgId } = {})

Source from the content-addressed store, hash-verified

12 * @return {Promise}
13 */
14 fetch ({ author = '', pageIdx = 1, quantity = 10, msgId } = {}) {
15 let url = '/msg/'
16
17 if (msgId) {
18 url += msgId
19 } else {
20 url = `${url}?author=${author}&pageIdx=${pageIdx}&quantity=${quantity}`
21 }
22
23 return xhr({ url })
24 }
25
26 /**
27 * 新增 msg

Callers 3

fetchMsgFromAPIMethod · 0.80
updateStateMethod · 0.80
fetchMsgFunction · 0.80

Calls 1

xhrFunction · 0.85

Tested by

no test coverage detected