Thursday 20 December 2018

Beginner with problems working with the Harvest API and getting paged results

HiI am fairly new to JS and Node.JS so please bear with me while I try and explain.​I am working with the Harvest API (https://ift.tt/2I5xCa3) which returns 100 results per page with added pagination.​EG{"projects":[{"id":14308069,"name":"Online Store - Phase 1","code":"OS1","is_active":true,"bill_by":"Project","budget":200.0,"budget_by":"project","budget_is_monthly":false,"notify_when_over_budget":true,"over_budget_notification_percentage":80.0,"over_budget_notification_date":null,"show_budget_to_all":false,"created_at":"2017-06-26T21:52:18Z","updated_at":"2017-06-26T21:54:06Z","starts_on":"2017-06-01","ends_on":null,"is_billable":true,"is_fixed_fee":false,"notes":"","client":{"id":5735776,"name":"123 Industries","currency":"EUR"},"cost_budget":null,"cost_budget_include_expenses":false,"hourly_rate":100.0,"fee":null}],"per_page":100,"total_pages":1,"total_entries":2,"next_page":null,"previous_page":null,"page":1,"links":{"first":"https://api.harvestapp.com/v2/projects?page=1&per_page=100","next":null,"previous":null,"last":"https://api.harvestapp.com/v2/projects?page=1&per_page=100"}}​I am trying to create a function which paginates the results and appends each of the paged results into a single set. I believe that I need to use Async Iterators but I am not too sure and I don't have anything to show at the moment, sorry.​Some links which you may find useful:​Node codehttps://github.com/harvesthq/harvest_api_samples/blob/master/v2/harvest_api_sample.js​Pagination Infohttps://help.getharvest.com/api-v2/introduction/overview/pagination/​Project Objecthttps://help.getharvest.com/api-v2/projects-api/projects/projects/​Any pointers would be great.Thanks for your time.​Al

Submitted December 20, 2018 at 10:25PM by alan-alan-alan

No comments:

Post a Comment