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

api.fetch method, only accepts json responses? #66

Closed
migueloop opened this issue Jan 16, 2018 · 4 comments
Closed

api.fetch method, only accepts json responses? #66

migueloop opened this issue Jan 16, 2018 · 4 comments
Assignees

Comments

@migueloop
Copy link

Hello,

I've been using api.fetch in a page to get data but having a look to the class it's not possible to get other data than a json response from the server, right?

If we use another lib, we will loose state management done in this pawjs/src/libs/api/api.js file, right?

@tirthbodawala
Copy link
Member

@migueloop Well yes you are right, the default we are using is "universal-fetch" and "api" library we created is tightly bound to it.

But you can directly use "universal-fetch" for other responses.

import fetch from "universal-fetch";

fetch("https://someapi.com/xml-endpoint", {})
  .then()
  .catch()

The package usage can be found here: https://github.com/Pitzcarraldo/universal-fetch

But now as you raised this question It got me thinking if we can customize the API library for other responses as XML, HTML etc. What are you exactly looking for?

@migueloop
Copy link
Author

I was getting HTML response. Since server is also mine, I just changed to a json response, but could be nice to have other response types.

@migueloop
Copy link
Author

I will try to make a pull request just changing this fact. Should we use a different library like axios or request?

@tirthbodawala
Copy link
Member

Well @migueloop I was more aligned to ES6 fetch "whatwg-fetch" with new html5 and thus included it. We can definitely try installing other options but would like to research properly.

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

No branches or pull requests

2 participants