Git Product home page Git Product logo

node-json-rest-client's People

Contributors

danieltdt avatar dependabot[bot] avatar oskosk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-json-rest-client's Issues

Work with base path

Maybe this is just a documentation issue, but right now I have to add my 'base path' to each of my resource definitions:

var rest = require('json-rest-client')({
        url: 'https://myapi.com/api/v1'
    }, {
        headers: {
            'X-Client-Version': 'NodejsClient 0.0.1',
            'Authorization': 'Bearer ' + config.token
        }
    });

return {
        users: rest.resource('/api/v1/users') // Have to include path here otherwise it doesn't work
    };

It would be nice to have just the path appended to the base path.

Be able to pass params to 'all()' and 'show()'

I was playing with the library the other day, and I may be mistaken but it would be nice to be able to optionally pass params to all() and show() to do things like pagination and search for example.

Issue with callback within restify

When using this library, I believe there is an issue with the performRequest function just haven't had the time to diagnose why.

var assert = require('assert');

function ICMClient(config) {
    assert(config, 'Config object must be present');
    assert(config.token, 'Token must be present in config');

    var rest = require('json-rest-client')({
        url: config.url
    }, {
        headers: {
            'X-Client-Version': 'NodejsClient 0.0.1',
            'Authorization': 'Bearer ' + config.token
        }
    });

    return {
        users: rest.resource('/api/v1-DEV/users')
    };
}

//url and token have been removed
var client = ICMClient({url: 'myapiurl', token: 'mytoken'});

var users = client.users().all();

module.exports = ICMClient;

Produces the following stacktrace:

/Users/vincent/WebstormProjects/icm-nodejs-client/node_modules/json-rest-client/node_modules/restify/lib/clients/json_client.js:84
        callback((err || null), req2, res, obj);
        ^
TypeError: undefined is not a function
    at parseResponse (/Users/vincent/WebstormProjects/icm-nodejs-client/node_modules/json-rest-client/node_modules/restify/lib/clients/json_client.js:84:9)
    at IncomingMessage.done (/Users/vincent/WebstormProjects/icm-nodejs-client/node_modules/json-rest-client/node_modules/restify/lib/clients/string_client.js:151:17)
    at IncomingMessage.g (events.js:180:16)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickCallback (node.js:419:13)

Add some sort of exclude property for .resource()

It would be nice when doing rest.resource('/articles',... to be able to specify which methods to exclude. The use case here is we have multiple resources in our API that you can create, but not update for example.

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.