JSON.stringify 하지 않고, 하위 오브젝트가 [Object]로 표시되는 것을 방지하는 방법이 있다. 원래 console.log는 자동으로 오브젝트를 인식하는 반면, console.dir은 오브젝트 전용이다. 이때 2번째 파라메터는 옵션을 받는데 여기서 depth: null로 주면, 무한대의 하위 오브젝트에 대해서 [Object]로 나오는 것을 방지해주고 실제 오브젝트가 문자열로 표시된다. console.dir(myObject, {depth: null})
var request = require('request'); var url = 'https://fcm.googleapis.com/fcm/send';var apikey = 'AAAA3WrrgCQ:APA91bHQnxgfAP4hurrF3OyBGla-oU3IO3cU9L6BmAvlmm1Ifbm130tTCqttTU2nJiOI4Q5_0-mdz5ht-d_6hLTW9XqvE1TDfIHTYOhsHipFNjwDNnKNRoKl7gnztok2_ZJC45j2k???'; //fcmvar token = 'dJvWJi4Kwss:APA91bGyIma2jGAXvAGV75zlEhY9fo8ev0QFUevFy5tIY6aazHQIImHUdOkuMdzWESGUgjULB2Swy-o4Q07k_37PqZ8-9WXqE1gwko4Z2v3Mw55PjR1qB..
var request = require('request'); // 둘다 사용가능 //var url = 'https://gcm-http.googleapis.com/gcm/send';var url = 'https://android.googleapis.com/gcm/send'; var apikey = 'AIzaSyAIwJr4nbF7jcDu9DUt4OdyTB_vEW3j???'; // project server key 1 (OK)var regId='cTUTljnS8XQ:APA91bF-Cv2MWOXHWF2nTBR8UdyxSMcWw6CJceEb7dVEj1r9MaevYbExzPkXDZLUDYuIJKXk-N83BN9x6yt6ZXEFGRJNEh7OW6qm4mw4jx-O9khNevsnPL71cOsiedqWdYmnux_rp?..
이더리움에서 일반 이더를 송금할 때는 이벤트를 받을수가 없다. 따라서 다음과 같이 filter를 걸어서 block안의 transactions에 우리가 원하는 transactionHash가 포함되었는지를 확인함으로서 송금이 완료되었는지를 확인할수 있다.아래의 소스코드는 node.js로 작성하였다. // 이더리움 web3에 접속 var EthConn = require('../contracts/ethconn.js');var host = 'http://localhost:8545'var ethconn = new EthConn(host);console.log(ethconn.web3.eth.accounts); var web3 = ethconn.web3;var eth = web3.eth;var personal = we..
npm install시 아래와 같은 에러메세지가 발생하였다.npm ERR! Cannot read property '0' of undefind 원인을 생각해보니 npm 5.6.0을 설치한 이후부터 이러한 문제가 발생하기 시작했다.그래서 다시 npm i -g npm@5.3.0을 실행하여 npm을 5.3.0으로 다운그레이드 하고 다시 했더니 없어졌다. 아참 그전에 node_modules 폴더는 삭제해야 반영된다.
서버 - index.js const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 8080 }); wss.on('connection', function connection(ws, request) { console.log('connection'); ws.on('message', function incoming(message) { console.log('received: %s', message); }); ws.on('close', function close(code, reason) { console.log('close ' + code + ':'+reason); }); ws.send('something'); }); 클라이언트 - ind..
/etc/nginx/site-availables/default에 다음과 같이 추가 location /api/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:3000/; proxy_redirect off; }
- Total
- Today
- Yesterday