當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript request.post函數代碼示例

本文整理匯總了TypeScript中request.post函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript post函數的具體用法?TypeScript post怎麽用?TypeScript post使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了post函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

    output.on('close', function () {
        var options = {
            method: 'POST',
            url: url.resolve(serviceEndpoint, '/v2/build'),
            encoding: 'binary'
        };
        console.log('Invoking the CloudAppX service...');

        var req = request.post(options, function (err: any, resp: any, body: string) {
            if (err) {
                return callback && callback(err);
            }

            if (resp.statusCode !== 200) {
                return callback && callback(new Error('Failed to create the package. The CloudAppX service returned an error - ' + resp.statusMessage + ' (' + resp.statusCode + '): ' + body));
            }

            fs.writeFile(outputPath, body, { 'encoding': 'binary' }, function (err) {
                if (err) {
                    return callback && callback(err);
                }

                fs.unlink(zipFile, function (err) {
                    return callback && callback(err);
                });
            });
        });

        req.form().append('xml', fs.createReadStream(zipFile));
    });
開發者ID:VvanGemert,項目名稱:hwa-cli,代碼行數:30,代碼來源:cloudAppx.ts

示例2: Promise

 return new Promise((resolve,reject) => {
   console.log(`posting ${url} form: ${JSON.stringify(formData)}`);
     request.post({url:url,formData:formData}, (err,response,body)=> {
         console.log(`post ${url} body ${JSON.stringify(formData)} err ${err} body ${body}`);
         err && reject(err) || resolve(body);
     })
 });
開發者ID:yedf,項目名稱:wx-rest,代碼行數:7,代碼來源:util2.ts

示例3: opn

 }).then((desc: string) => {
     let data = {
         "description": desc,
         "public": true,
         "files": {}
     }
     data.files[filename] = {"content": code};
     
     let opts = {
         url: 'https://api.github.com/gists',
         body: data,
         json: true,
         headers: {
             'User-Agent': 'request'
         }
     }
     
     if (userName != null && userPass != null) {
         opts['auth'] = {
             user: userName,
             pass: userPass
         }
     }
     
     request.post(opts, (err, httpResponse, body) => {
         vscode.window.showInformationMessage("Your File is published here: " + body.html_url);
         opn(body.html_url)
     });
 })
開發者ID:gitter-badger,項目名稱:VSCode-ShareCode,代碼行數:29,代碼來源:extension.ts

示例4: Promise

  let promise: Promise<INeo4jIndexResponse> = new Promise((resolve, reject) => {
    let normalizedPropertyNamesArray: string[] = [];
    if (typeof propertyNames === "string") {
      normalizedPropertyNamesArray.push(propertyNames);
    } else {
      normalizedPropertyNamesArray = propertyNames;
    }

    let indexEndpointString: string = `${graphPaths.indexes}/${label}`;
    try {
      requestOptions.body = JSON.stringify({ "property_keys": normalizedPropertyNamesArray });
    } catch (ex) {
      reject(ex);
    }
    request.post(indexEndpointString, requestOptions, (err, response, body) => {
      if (err) {
        reject(err);
      }
      if (response.statusCode !== 200) {
        reject(`Error creating index on label ${label}. HTTP Status Code: ${response.statusCode}. HTTP Body: ${body}`);
      }
      body = typeof body === "string" ? JSON.parse(body) : body;
      resolve(body);
    });
  });
開發者ID:tpennetta,項目名稱:neo4j-typescript,代碼行數:25,代碼來源:index.ts

示例5: Promise

	return new Promise((resolve, reject) => {
		request.post('http://dpaste.com/api/v2/', { form: { content: code, syntax: syntax, title: title, expiry_days: 7 } }, (err, httpResponse, body) => {
			if (err)
				return reject(err);
			resolve(body);
		});
	});
開發者ID:claudiug,項目名稱:code-d,代碼行數:7,代碼來源:util.ts

示例6: Promise

 return new Promise((resolve, reject) => {
     request.post("http://3ds.pokemon-gl.com/frontendApi/gbu/getSeasonPokemonDetail", {
         headers: {
             "Origin": "http://3ds.pokemon-gl.com",
             "Referer": "http://3ds.pokemon-gl.com/battle/oras/",
             "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
             "User-Agent": "CuBoid"
         },
         form: {
             "languageId": "2",
             "seasonId": "108",
             "battleType": "2",
             "timezone": "BST",
             "pokemonId": pokemon,
             "displayNumberWaza": "10",
             "displayNumberTokusei": "3",
             "displayNumberSeikaku": "10",
             "displayNumberItem": "10",
             "displayNumberLevel": "10",
             "displayNumberPokemonIn": "10",
             "displayNumberPokemonDown": "10",
             "displayNumberPokemonDownWaza": "10",
             "timestamp": Date.now().toString()
         }
     }, (err, response, body) => {
         if (err) {
             reject(err);
         } else {
             resolve(JSON.parse(body));
         }
     });
 });
開發者ID:Cu3PO42,項目名稱:CuBoid,代碼行數:32,代碼來源:pokemonGl.ts

示例7: ApiCall

 private ApiCall(apiType:string, data?) {
     var that = this;
     
    if (!this._statusBarItem) { 
        this._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left); 
    }
    
    request.post({
        url: BASE_URL+apiType, 
        formData: data
    }, function (error, response, body) {
            if (!error && response.statusCode == 200) {
                switch(apiType) {
                    case API_SET_SNOOZE: case API_END_SNOOZE:
                        that._statusBarItem.text = "$(bell) Status set successfully!";
                        break;
                    case API_UPLOAD_FILES:
                        that._statusBarItem.text = "$(file-text) File sent successfully!";
                        break;
                    default:
                        that._statusBarItem.text = "$(comment) Message sent successfully!";
                        break;
                }
                that._statusBarItem.show(); 
                setTimeout(function() { that._statusBarItem.hide()}, 5000 );
            }
    });
 }
開發者ID:avica,項目名稱:vscode-slack,代碼行數:28,代碼來源:extension.ts

示例8: Logger

  .on('file', (fields: Fields, file: any) => {
    let formData = {
      type: CONST.IMAGE_TYPES.AVATAR,
      path: filePath,
      file: {
        value: fs.createReadStream(file.path),
        options: {
          filename: UTIL.renameFile(file.name)
        }
      }
    }

    request.post({
      url: SERVERS.UPLOAD_SERVER,
      formData
    }, (err: Error, response, body) => {
      if (err) console.log(err)

      let fileName = JSON.parse(body).files[0],
        filePath = path.join(now, fileName)

      UserModel
      .findByIdAndUpdate(creator, {avatar: filePath}, {new: true})
      .then((user: IUser) => {
        if (user) {
          res.status(200).json(UTIL.getSignedUser(user))
          new Logger(log)
        }
      })
      .catch((err: Error) => {
        new Err(res, err, log)
      })
    })
  })
開發者ID:yeegr,項目名稱:SingularJS,代碼行數:34,代碼來源:UserController.ts

示例9: it

 it('should not authorize without header', (done) => {
     request.post('http://localhost:5674/authorization/methods/profile',
         (error, response, body) => {
             expect(response.statusCode).to.eq(401);
             done();
         });
 });
開發者ID:thiagobustamante,項目名稱:typescript-rest,代碼行數:7,代碼來源:authenticator.spec.ts


注:本文中的request.post函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。