How to use the agent function from superagent

Find comprehensive JavaScript superagent.agent code examples handpicked from public code repositorys.

104
105
106
107
108
109
110
111
112
113
/*
 * Used to save and return cookies in a node.js (non-browser) setting,
 * if this.enableCookies is set to true.
 */
if (typeof window === 'undefined') {
  this.agent = new superagent.agent();
}

// API Routes
this.activityFeed = new ActivityFeed(this);
fork icon37
star icon0
watch icon1

2
3
4
5
6
7
8
9
10
11
console.log('open library connector loading...')

const URL = 'https://openlibrary.org/search.json?q='

exports.search = async (query) => {
  const agent = request.agent()
  const responseData = { books: [] }

  try {
    const searchRequest = await agent.get(URL + query).timeout(1000)
fork icon1
star icon11
watch icon2

32
33
34
35
36
37
38
39
40
41
42
43
 */
exports.login = function (params) {
  params = params || {}


  // 保存Cookie
  var agent = request.agent()


  if (params.studentId && params.passWord) {
    // 登录图书馆
    return agent
fork icon3
star icon4
watch icon2

+ 9 other calls in file