我正在连接到sails api,并使用以下代码获取上述错误。 http://myurl.com也具有html页面,路径http://myurl.com/api2/具有api
import socketIOClient from 'socket.io-client';
import sailsIOClient from 'sails.io.js';
componentDidMount() {
var io = sailsIOClient(socketIOClient);
// Set some options:
// (you have to specify the host and port of the Sails backend when using this library from Node.js)
io.sails.url = 'http://myurl.com';
console.log('url', io.sails.url)
var test = io.socket.get('/api2/task', function serverResponded (body, JWR) {
// body === JWR.body
console.log('Sails responded with: ', body);
console.log('with headers: ', JWR.headers);
console.log('and with status code: ', JWR.statusCode);
// ...
// more stuff
// ...
// When you are finished with `io.socket`, or any other sockets you connect manually,
// you should make sure and disconnect them, e.g.:
io.socket.disconnect();
// (note that there is no callback argument to the `.disconnect` method)
});
}