Commit ae865ec1 authored by Mycha de Vrees's avatar Mycha de Vrees
Browse files

transformer cleanup

parent ac5c28b4
Pipeline #363 passed with stage
in 1 minute and 27 seconds
......@@ -71,11 +71,9 @@ function _mapResponse (response) {
...include.attributes
}
if (Object.hasOwnProperty.call(include, 'relationships')) {
// todo fix me
for (const key in include.relationships) {
if (Object.hasOwnProperty.call(include.relationships, key) &&
include.relationships[key].data && include.relationships[key].data.length > 0
) {
include.relationships[key].data && include.relationships[key].data.length > 0) {
obj.authors = _fetchIncludes({
relation: include,
response,
......@@ -93,17 +91,18 @@ function _mapResponse (response) {
}
function _mapSingleResponse (response) {
const res = response.data.data
const obj = {
id: response.data.data.id,
...response.data.data.attributes
id: res.id,
...res.attributes
}
if (Object.hasOwnProperty.call(response.data.data, 'relationships')) {
for (const key in response.data.data.relationships) {
if (Object.hasOwnProperty.call(response.data.data.relationships, key) &&
response.data.data.relationships[key].data &&
response.data.data.relationships[key].data.length > 0) {
for (const key in res.relationships) {
if (Object.hasOwnProperty.call(res.relationships, key) &&
res.relationships[key].data &&
res.relationships[key].data.length > 0) {
obj[key] = _fetchIncludes({
relation: response.data.data,
relation: res,
response,
type: key,
typeAlias: _mapTypeAlias(key),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment