busboy不发射现场事件

时间:2018-01-17 01:27:52

标签: node.js busboy

在下面的代码中,我只能看到结束事件发生而不是现场事件。

const Busboy = require('busboy');

module.exports.controller = function(app) {
    app.post('/api', function(req, res) {
        var busboy = new Busboy({ headers: req.headers });
        var formdata = {};
        busboy.on('field', function (fieldname, val) {
            console.log("fieldname : " + fieldname);
            console.log("value : " + val);
            formdata[fieldname] = val;
        });
        busboy.on('finish', function() {
            res.send(formdata);
        });
        req.pipe(busboy);
    });
};

作为回应,我在邮递员处收到{}。这可能会出现什么问题?

1 个答案:

答案 0 :(得分:0)

我知道这早就该开始了,但是我也遇到了这个问题,然后我意识到我在HTML输入中缺少<Package ... xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp uap5 rescap"> ... <Capabilities> <rescap:Capability Name="broadFileSystemAccess" /> </Capabilities> 字段。

工作片段:

<?php
//dynamically build chart queries
$sql_prep = "SELECT d.store_list AS NUMB, s.name AS NAME FROM data d INNER JOIN store_list s ON d.store_list=s.store_id WHERE d.status != '' AND d.store_list IN (" . $user_stores . ") GROUP BY store_list";
$sql_code = $conn->query($sql_prep);
$select = '';
    while($row = $sql_code->fetch_assoc()) {
        $select .= ", CAST(((SUM(CASE WHEN LOWER(`q3`) = 'no' AND store_list = " . $row['NUMB'] . " THEN 1 ELSE 0 END)/SUM(CASE WHEN store_list = " . $row['NUMB'] . " THEN 1 ELSE 0 END))*100) as decimal (10,1)) AS  '" . $row['NAME'] . "' ";
        $cstores = $cstores . "'" . $row['NAME'] . "', " ;

    }
?>

<!--https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
  google.charts.load('current', {'packages':['corechart']});
  google.charts.setOnLoadCallback(drawChart1);

  function drawChart1() {
    var data = google.visualization.arrayToDataTable([
    ['Month', <?php echo $cstores ?>],
    <?php 

        $sql = "SELECT
                QUOTE(DATE_FORMAT(date_submitted,'%b-%y')) AS 'Month'
                ". $select ."
            FROM data 
            WHERE store_list IN (" . $user_stores . ")
            GROUP BY YEAR(date_submitted), MONTH(date_submitted)
            ORDER BY YEAR(date_submitted) ASC, MONTH(date_submitted) ASC";

        $Sat = mysqli_query($conn,$sql);
        foreach( $Sat as $key => $array ) {
            echo("[");
            foreach( $array as $attribute => $value ) {
                echo $value. ",";
            }
            echo("],");
        }
    ?>