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

Solidus REST API Headless #3076

Open
CharlyJazz opened this Issue Feb 5, 2019 · 8 comments

Comments

Projects
None yet
4 participants
@CharlyJazz
Copy link

CharlyJazz commented Feb 5, 2019

Is it possible to use Solidus REST API to create SPA, PWA, or simply consult an endpoint to filter products?

I refer to the Front End as such, not using the API to create an Admin panel

@CharlyJazz

This comment has been minimized.

Copy link
Author

CharlyJazz commented Feb 5, 2019

I can not find a way to filter a product asynchronously using XMLHTTPREQUEST.

@kennyadsl

This comment has been minimized.

Copy link
Member

kennyadsl commented Feb 5, 2019

@CharlyJazz yes, you can include only engine that you need. Instead of:

gem 'solidus'

You could do:

gem 'solidus_core'
gem 'solidus_api'
gem 'solidus_backend'
gem 'solidus_sample'

and implement your own frontend.

I can not find a way to filter a product asynchronously using XMLHTTPREQUEST.

Not sure to get what you mean. Can you please explain better?

@CharlyJazz

This comment has been minimized.

Copy link
Author

CharlyJazz commented Feb 5, 2019

I'm trying to filter, or do anything like

Obtain products or taxonomies using the REST API ... etc.

But I can only use the REST API if I have a token from a user Admin and that does not make sense for the Front End. I need to do AJAX because I want to make a modern web with React (Single Page App).

Example: If i can try make a ajax using the endpoint: https://ecommerce.herokuapp.com/api/products/1 i get:

{"error":"You must specify an API key."}

@kennyadsl

This comment has been minimized.

Copy link
Member

kennyadsl commented Feb 5, 2019

Yes you are right, there's no built in way to use the API without an API key. This can be solved in several ways, see. #2808 and the resulting extension https://github.com/skukx/solidus_jwt for an example of implementaion using JWT.

@ericsaupe

This comment has been minimized.

Copy link
Contributor

ericsaupe commented Feb 5, 2019

@CharlyJazz pretty sure by default all API calls require authentication. You can remove this overarching requirement by changing the API config.

Spree::Api::Config.configure do |config|
  config.requires_authentication = false
end

This will disable authentication for public calls but still maintain normal permission checks on things like orders and users.

@CharlyJazz

This comment has been minimized.

Copy link
Author

CharlyJazz commented Feb 6, 2019

@ericsaupe Thats gold. We need that in the documentation. The people want create PWA, and modern front end architectures.

@ericsaupe

This comment has been minimized.

Copy link
Contributor

ericsaupe commented Feb 6, 2019

Definitely something that can be better documented. I'll see if I can get a PR open with some better documentation for this gotcha. We did a single page checkout using the solidus_api and ran into this.

Thanks for the question!

@CharlyJazz

This comment has been minimized.

Copy link
Author

CharlyJazz commented Feb 6, 2019

Thank for u support bro! @ericsaupe 🎉 🎉

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