Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createResource Issue #214

Open
rehanrehman389 opened this issue Nov 10, 2024 · 0 comments
Open

createResource Issue #214

rehanrehman389 opened this issue Nov 10, 2024 · 0 comments

Comments

@rehanrehman389
Copy link

rehanrehman389 commented Nov 10, 2024

When i try with following ways i got some issues,

let todo = createResource({
    url: 'http://127.0.0.1:8000/api/method/ping',
    method: 'GET'
  })

  todo.fetch()

image

let todo = createResource({
    url: 'http://127.0.0.1:8000/api/resource/ToDo',
    method: 'GET'
  })

  todo.fetch()

image

  let todo = createResource({
    url: 'http://127.0.0.1:8000/api/resource/ToDo',
    method: 'GET',
    headers: {
      'Authorization': `token 73b6530029d4dea:eee2a9432d87585`,
    }
  })

  todo.fetch()

image

  async function fetchAllFields() {
    try {
        const response = await fetch('https://jsonplaceholder.typicode.com/posts/1', {
            method: 'GET',
        });

        if (!response.ok) {
            throw new Error(`Error: ${response.status}`);
        }

        const data = await response.json();
        console.log(data);
    } catch (error) {
        console.error("Fetch error:", error);
    }
}
fetchAllFields()

image

  let postVar = createResource({
  url: 'https://jsonplaceholder.typicode.com/posts/1',
  method: 'GET',
})
postVar.fetch()

image

let postVar = createResource({
  url: 'http://127.0.0.1:8000/api/method/finsta.finsta.doctype.post.post.get_posts_with_likes_and_comments',
  method: 'GET',
})
postVar.fetch()

image

It is working when i call api which is whitelisted otherwise it is not getting any data in response as i showed in 1,2,3 and 5??

@netchampfaris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant