Giter VIP home page Giter VIP logo

Comments (6)

prophet60091 avatar prophet60091 commented on July 26, 2024 1

Did you ever get this handled? I was having the same issue. On node 6.9.1. Setting limit without a constraint returns just fine of course.

In looking into it I think that this has been fixed or at least the code is currently much different in the master than what I was using in my project. I think at issue is that your tutorial (maybe @johnsonice was using this? https://www.youtube.com/watch?v=OhPFgqHz68o&t=3775s) If they followed that or just used https://github.com/travist/meanapp/tree/resourcejs/server to get started, it calls for v0.1.25, and this version still suffers from the bug that was fixed on 4/5/16 62ff2a5

I fixed it in that old version, in case anyone is unsure about the consequences of using the current version in their project by changing lines 323-324

.limit(parseInt(req.query.hasOwnProperty('limit') ? req.query.limit : pageRange.limit))
.skip(parseInt(req.query.hasOwnProperty('skip') ? req.query.skip : pageRange.skip))

Because for some reason it was not being considered an int.

Btw, @travist Thanks for the help in getting me started with my first REST API - I almost got excited that I had found and fixed a bug ;) for you.

from resourcejs.

zackurben avatar zackurben commented on July 26, 2024

@johnsonice can you provide example urls that you used, which didn't work?

from resourcejs.

cycz1235 avatar cycz1235 commented on July 26, 2024

@zackurben thanks for your quick response

here is an example
http://localhost:3000/resource?limit=99
i tried http://localhost:3000/resource?limit it will just retrieve everything in the collection.
and this http://localhost:3000/resource?limit=-99 actually worked, returned 99 items. But i don't think it is how it should be.

no luck with ?skip at all.

I am very new to this. it could be I made a stupid mistake somewhere, but i just can't figure it out

from resourcejs.

zackurben avatar zackurben commented on July 26, 2024

@cycz1235 both skip and limit should work as follows:

example.com/resource?limit=5
example.com/resource?limit=5&skip=5

You can actually see them in the tests here: https://github.com/travist/resourcejs/blob/master/test/test.js#L688-L734

Just for background knowledge, what version of node are you running? I don't think this is an issue with ResourceJS, since the tests haven't complained, but maybe the version will tell us more.

Zack

from resourcejs.

johnsonice avatar johnsonice commented on July 26, 2024

@zackurben i am running on node v5.4.0

from resourcejs.

claytongulick avatar claytongulick commented on July 26, 2024

Is there a place in the docs where the use of limit, skip etc... are mentioned? I see tests for them, but nothing mentioning their use.

from resourcejs.

Related Issues (20)

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.