Solidus: Solidus REST API Headless

Created on 5 Feb 2019  路  9Comments  路  Source: solidusio/solidus

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

Question

All 9 comments

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

@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?

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."}

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.

@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.

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

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!

Thank for u support bro! @ericsaupe :tada: :tada:

We recently merged #3133 and I think we can close this one since our API is fully documented. Thanks for your question @CharlyJazz!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kennyadsl picture kennyadsl  路  3Comments

graygilmore picture graygilmore  路  5Comments

jhawthorn picture jhawthorn  路  4Comments

aitbw picture aitbw  路  4Comments

iqre8 picture iqre8  路  4Comments