请告诉我该怎么做 server.js
app.get('/playlist', (req, res) => {
fetch("http://www.bbc.co.uk/radio1/playlist.json")
.then((res) => res.json())
.then((data) => {
res.send(data);
})
.catch((err) => {
res.writeHead(500);
res.end("Failed to load data: " + err);
});
})
React app.js:
componentDidMount() {
axios.get('/playlist').then(function(response){
alert(response)
}).catch(function(error){
alert(error)
});
}