0

I have a GET_LIST that calls an API, displaying me an object of data. But when I create the Edit component which is under the same resource component, I am calling a second API call that shows additional data for that GET_ONE item.

My issue, is that although I can configure a GET_ONE call inside my rest client, I am unable to get the Edit component do use the GET_ONE API call response object. It is still using the GET_ALL API call response object.

Here's some sample code. Note, that my GET_ONE api call doesn't have {resource} because the URL link doesn't have that word.

const API_URL = 'https://api.link/biglist';
const 2API_URL2 = 'https://api.link/address=123456';
switch (type) {
  case GET_LIST: {
    url = `${API_URL}/${resource}`;
    break;
  }
  case
  GET_ONE:
    url = `${2API_URL2}/${params.id}`;
    break;

Inside the Edit component, I have an ImageField. By console logging the record inside the ImageField component, I can see that the record response object is using the GET_ALL API response, instead of GET_ONE API response.

I have made sure that when I access the Edit component of a specific item inside the GET_LIST, my Edit component does indeed make an API call to my secondary API request, and it does return me the response object of the secondary request. I just can't somehow map the secondary API response with record inside ImageField.

So my question is, how do I get the GET_ONE response inside my Edit component (which is under the same resource component) to use my second API response and map it with record?

Mjaaay
  • 15
  • 7

1 Answers1

0

I solved my problem by adding a fetch API call inside my resource components, and created custom field components to use my secondary API calls instead of using record. I feel there's a much better solution, but this'll do.

Mjaaay
  • 15
  • 7