我想检索我喜欢的帖子。我已编写代码但显示错误。
facebookDataUrl = "http://graph.facebook.com/yourstory.com/2016/04/shotpitch-startup-trended-product-hunt/"
console.log facebookDataUrl
data = Http::curl(facebookDataUrl)
fbshares = json_decode(data, true)
fbsharescnt = fbshares['shares']
console.log fbsharescnt
以上代码显示错误
fbshares = json_decode(data, true);
^
ReferenceError:未定义json_decode
答案 0 :(得分:1)
使用JSON.parse()
。
get = require 'http-get-shim'
url = 'http://graph.facebook.com/yourstory.com/2016/04/shotpitch-startup-trended-product-hunt/'
get url, (er, resp, body) ->
data = JSON.parse body
console.log data