-
Notifications
You must be signed in to change notification settings - Fork 58
couple of questions about usage #109
Comments
@MurhafSousli I need to turn in for the night but I'll try to review this Monday or Tuesday my time—thanks for the questions! If you haven't heard from me in 3 days feel free to bump this issue. Edit: I've been doing triage on my generic JS client and didn't realize what repo I was in; I thought this was a follow-up to WP-API/node-wpapi#149 ! — @adamsilverstein is going to be better able to help out with this than I :) Too many Adams... |
Hello @MurhafSousli, Glad to hear you are using the library. The main thing this library provides are Models and Collections matching all the endpoints available in the WP-API. A Model represents a single item in the API and WordPress, for example a Post. A Collection is a group of models, for example a collection of posts. Util and Load are primarily for internal functions, I don't think you need to use them except to help develop the library. You are right that collections are often read only (or can save new models, but not edit them) and models generally support all CRUD methods. You can check what each endpoint does by examining the API schema, and each Model/Collection also provides information about the available methods in the Here are some answers to your questions:
var post = new wp.api.models.Post( { id: 1 } );
var postPromise = post.fetch();
postPromise.done( function( model ) { ...
do something
} );
Let me know if you have further questions, good luck. Closing for now, re-open if you have additional questions. |
Thank you so much. |
Hi, first of all thank you for the great job you do in this library, I'm currently using only
Collections
to get everything I need from wordpress, but there are some things I want to confirm.What I understood till now:
because I want to get the most out of this great library, I have couple of questions:
utils.js
converts the date format but couldn't figure out if I can use it.wp.api.models.Posts.defaults
is this the class?Models
? if so please show me how to usewp.api.collections
after I finish using it? before using this library I used to useObservable
from rxjs 5 and they don't need to be disposedyou can check how I'm using the library in my service file here
The text was updated successfully, but these errors were encountered: