Getting error when returning list from rest service admin-on-rest -


i'm getting following error on first admin component.

uncaught @ handlefetch typeerror: newrecords.reduce not function

when attempt query rest-api. i'm using majority of supplied simple rest client additional security headers thrown in.

my response api is:

http/1.1 200 ok transfer-encoding: chunked content-type: application/json; charset=utf-8 content-range: account 0-0/1 server: kestrel access-control-allow-origin: * access-control-expose-headers: content-range request-context: appid=cid-v1:9f32da6c-a0dd-445f-b59f-d5d01ee6c462 x-aa-request-id: ad76be2b-0a29-4179-8fab-6ac0b83e411b x-sourcefiles: =?utf-8?b?rtpcrgv2xefbshvixefblkh1yi5tzxr0aw5ncy5tzxj2awnlxefblkh1yi5tzxr0aw5ncy5tzxj2awnlxgfwavx2mvxhy2nvdw50?= x-powered-by: asp.net date: tue, 15 aug 2017 02:56:56 gmt 

the body of response has:

{"data":[{"changemanagements":[],"serviceprofiles":[],"id":1,"login":"cuken","permissionlevel":9001,"note":"this dev test user"}],"totalitems":1} 

edit

here fetch.js file modified simple rest client example:

import httperror './httperror';  export const fetchjson = (url, options = {}) => {     const requestheaders = options.headers || new headers({         accept: 'application/json',         'x-aa-clientname': 'fc5f3712-64fc-4ca4-9e5f-d4b6edeb46d4',         'x-aa-apikey': '80b4ccbf-a741-42ad-aacc-50c4309de8e6',     });     if (!(options && options.body && options.body instanceof formdata)) {         requestheaders.set('content-type', 'application/json');     }     if (options.user && options.user.authenticated && options.user.token) {         requestheaders.set('authorization', options.user.token);     }      return fetch(url, { ...options, headers: requestheaders })         .then(response => response.text().then(text => ({             status: response.status,             statustext: response.statustext,             headers: response.headers,             body: text,         })))         .then(({ status, statustext, headers, body }) => {             let json;             try {                 json = json.parse(body);             } catch (e) {                 // not json, no big deal             }             if (status < 200 || status >= 300) {                 return promise.reject(new httperror((json && json.message) || statustext, status));             }             return { status, headers, body, json };         }); };  export const queryparameters = data => object.keys(data)     .map(key => [key, data[key]].map(encodeuricomponent).join('='))     .join('&'); 

the simple.js file exact copy repo.

what did wrong?

you need dedicated auth client handle auth types , shoot appropriate actions

https://marmelab.com/admin-on-rest/admin.html#authclient


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -