1.2.6 • Published 7 years ago

req-to-json v1.2.6

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Simple express middleware to take data from an API get request and store in a file in your project. This node module also allows you to access the data in JSON format.

Methods currently:

  • getJSON
  • store
  • storeByField

To use in Node:

var express = require('express');

var jsonStore = require('req-to-json');

var app = express();


app.get('/', function(request, response) {
  
  // Store all

	jsonStore.store(url, fileName, function(err, data) {
       if(err) {
           // Do something with the error
       }
       else {
           // Do something with the data
       }
    });

  // Store by fields --> add specific data fields. E.g. (github --> ['login', 'id'])

  jsonStore.storeByField(url, fileName, fieldsArray, function(err, data) {
      if(err) {
           // Do something with the error
       }
       else {
           // Do something with the data
           //{
           // "login": "yourlogin", 
           // "id": 2343345
           //}
       }
  })

  // Similarly, to use the getJSON method 

  jsonStore.getJSON(fileName)
        .then(function(response) {
            // Handle success callback
         })
         .catch(function(error) {
             // Handle error callback
         });
  });

}

Built by Theodore Anderson

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.0

7 years ago

1.1.20

7 years ago

1.1.19

7 years ago

1.1.18

7 years ago

1.1.17

7 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago