React - 如何从服务器端到客户端获取值/变量

时间:2018-03-28 07:32:36

标签: reactjs express client-server display data-transfer

我的客户端拥有我文件夹中的所有文件名。

server.js

var express = require('express');
var formidable = require('formidable');

var app = express();
var fs = require('fs');

app.use(express.static(__dirname));

function test(){
        fs.readdir('./uploads/', function(err, files) {
                console.log(files); //here are the filename I wanted to get
                return files;
        });
}

Dropuploadfile.js

    render() {
    return (
        <div className="wrapper">
            <h1>Drop &amp; Upload Files</h1>
            <DropZoneBox url={this.props.url} onUploaded={this.appendThumbnail} />
            <Output files={this.state.files} />
            <br/>
            <h2>List of Uploaded File</h2>
            <div className="hh">
                <ul>
                  <li>Test</li> // how to display all the filename at here ????????
                    <li>Test</li>
                    <li>Test</li>
                </ul>
            </div>
        </div>
    );
}

我需要显示我在server.js获取的所有文件名,并在dropuploadfile.js中显示,如何?谢谢

0 个答案:

没有答案