Use a function inside an module.exports

I'm trying to build a module which encloses the following function inside:

    request urlString, (error, response, body) ->
        return JSON.parse(body) if !error && response.statusCode == 200

It's all enclosed by the module.exports. The function executes, but I'm not able to return the body from the callback in request.

Any suggestions?

i think what you want is parseJSON func. even though i may use this code directly:

#file requestJSON.js


requestJSON = (urlString, callback)->
    request urlString, (error, response, body) ->
        if !error && response.statusCode == 200
            bodyJSON = JSON.parse body
        calllback error,bodyJSON
        return

module.exports=requestJSON


#file requestJSON.usage.js

requestJSON = require "./requestJSON"
requestJSON "json API", (error,jsonData)->
    console.log jsonData
    return