bonjour, j'ai voulu rajouter la fonction 'getNetwork()'
et j'obtiens une erreur 500.
quelqu'un peut-il m'aider.
(attention je débute vraiment)
merci d'avance
f4gbv
voici un extrait du code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 const path = require('path') const promisify = require('util.promisify') const fs = require('fs') const config = require('../config') const readFile = promisify(fs.readFile) function getNetwork() { return readFile(path.join(config.dir, 'network'), 'utf8').then(v => v.trim()) } class Component extends React.Component { constructor() { super() this.state = {} this.handleNetworkChange = this.handleNetworkChange.bind(this) this.getNetwork = this.getNetwork.bind(this) } componentWillMount() { this.setState(this.props) this.state.network = {this.getNetwork} } componentDidMount() { const es = new EventSource('/stream') const fsm = new Fsm(es, () => { this.setState(fsm) }, this.props) es.onerror = error => { console.error('EventSource error', error) } } static getInitialProps() { return fetch('/api/svxlink').then(res => res.json()) } render() { return ( <Layout> <div className="form-inline"> <label className="sr-only" htmlFor="network">Network</label> <select required name="network" className="form-control" value={this.state.network} onChange={this.handleNetworkChange}>
Partager