Giter Site home page Giter Site logo

simple-web-request's Introduction

Simple Web request Tutorial

  1. Log into your newly created FeedHenry account
  2. Click on ‘Create an App’, then ‘Create an App From Scratch’.
  3. Call your app ‘Simple Web Request’, and give it a description.
  4. Select next, then finish.
  5. We’re going to write some NodeJS code to do a simple web request, and return raw JSON into our application. First, we need to include the module we’ll be using to do this, called ‘request’.
    Edit the file in the cloud directory called ‘package.json’, and add the content shown:
{
  "name": "fh-app",
  "version": "0.1.0",
  "dependencies" : {
    "fh-nodeapp" : "*"
    ,"request" : "2.16.6"
  }
}

See The Code

Here’s the cloud code we’re going to use to perform the request – add it to cloud/main.js:

var util = require('util');
var request = require('request');

exports.getConfig = function(params, callback) {
  request({uri: 'http://search.twitter.com/search.json?q=feedhenry', method: 'GET'},
  function (err, response, body) {
      // just apply the results object to the data we send back.
      var search = JSON.parse(body);
      callback(null, {config: search.results});
  });
};

See The Code

  1. Save all & verify this works in the studio by clicking the “Execute cloud action call” button in the previous.
  2. Try using some other JSON API’s on the web. All you should have to change is the request and the piece of JSON returned (as underlined above).
    See The Code

simple-web-request's People

Contributors

cianclarke avatar

Watchers

James Cloos avatar Brian Dooley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.