graphiti-api/spraypaint.js

Create Model Instance with Raw HTTP Request

Closed this issue · 1 comments

With some edge-cases, I need to do some manual requests, since I can't use Spraypaint for arbitrary endpoints.

Those requests return a Graphiti Response (JSON:API Spec) with associations. How can I transform this request into a Model Instance?

Best regards

I found a way:

let response = fetch('...')
let parsedData = JSON.parse(response.data);
parsedData.jsonResponse = parsedData;
let customer = Customer.fromJsonapi(parsedData.data, parsedData);