javascript - Problems using Parse.Cloud.httpRequest with Express, says no such method for success: -


i'm hitting facebook graph search url, in parse express. call made parse.cloud.httprequest.

i 500 internal server error response, , when in logs see:

  1. an error saying httprequest has no method named success: (even though code i'm using based right off examples on parse.com).
  2. the basic json data there retrieved error has prevented function completing.

here's code, tips appreciated:

// these 2 lines required initialize express in cloud code.  var module = require('cloud/jsonml.js');  var buffer = require('buffer').buffer;  var express = require('express');  var app = express();  // global app configuration section  app.set('views', 'cloud/views');  // specify folder find templates  app.set('view engine', 'ejs');    // set template engine  app.use(express.bodyparser());    // middleware reading request body    app.get('/hello', function(request, response) {     parse.cloud.httprequest({                             url: 'a-facebook-graph-url',                             success: function(httpresponse) {                             console.log(httpresponse.data);                             response.success(httpresponse.data);                             var xml = module.stringify(httpresponse.data);                             var base64xml = xml.data.base64;                             console.log(base64xml);                             res.render('hello.ejs',{ message: base64xml });                             },                             error:function(httpresponse){                             console.error('error:' + httpresponse.message);                             response.error("failed parse feed");                             res.render('hello.ejs',{ message: httpresponse.message });                             }         });      });   app.listen(); 

i use promises. seems work me:

parse.cloud.httprequest({       url: 'a-facebook-graph-url'     }).then(function(httpresponse) {       console.log(httpresponse.text);        var xml = module.stringify(httpresponse.data);       var base64xml = xml.data.base64;       res.render('hello',          {              message: base64xml          });     }, function(httpresponse) {       console.error('request failed response code ' + httpresponse.status);     }); 

more info parse website here


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -