You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I have encountered an error when deleting a relationship using the code: jsonApi.one('author', 1).relationships('articles').delete([{ id: 1 }])
The error I am getting is: Uncaught TypeError: schema_schema__WEBPACK_IMPORTED_MODULE_12. jsonApi.one(...).relationships(...).delete is not a function_
Could this be an internal issue with the package?
I am on the latest version of Devour-Client.
The text was updated successfully, but these errors were encountered:
You're right. In our own apps we're using a patch for this that probably should become part of the official devour-client, but only after improving.
Our code looks like this:
import{get,last,map}from"lodash"exportfunctiondestroyRelationships(relationshipName,ids,params={}){constlastRequest=last(this.builderStack)constmodelName=get(lastRequest,"model")if(!modelName){thrownewError("destroyRelationships must be called with a preceding model.")}constrelationship=this.relationshipFor(modelName,relationshipName)this.builderStack.push({path: "relationships"})this.builderStack.push({path: relationship.path,model: relationship.type})constdata=map(ids,(id)=>{return{type: relationship.type,id: id}})constreq={method: "DELETE",url: this.urlFor(),model: modelName,params: params,data: data,}if(this.resetBuilderOnCall){this.resetBuilder()}returnthis.runMiddleware(req)}
The thing with this code is that you cannot use it like you described (which would be totally logical to expect):
Hello, great work on this package!
However, I have encountered an error when deleting a relationship using the code:
jsonApi.one('author', 1).relationships('articles').delete([{ id: 1 }])
The error I am getting is:
Uncaught TypeError: schema_schema__WEBPACK_IMPORTED_MODULE_12. jsonApi.one(...).relationships(...).delete is not a function_
Could this be an internal issue with the package?
I am on the latest version of Devour-Client.
The text was updated successfully, but these errors were encountered: