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
Dillon Redding edited this page Dec 18, 2023
·
6 revisions
A requirement for any API client is parsing content from a server response. For a Siren client, we can use the parse function to transform content to an instance of an Entity.
We can use it to parse JSON text:
import{Entity,parse}from'@siren-js/client';constsiren=JSON.stringify(orderEntity);// orderEntity is from the Modeling page 👉constsameAsOrderEntity=awaitparse(siren);// specify the type of entity's `properties` using `parse`'s type parameterconstorderWithTypedProperties=awaitparse<OrderProperties>(siren);