У меня есть
(Домашний контроллер)
def default
users = Users.all
respond_to do |format|
format.html
format.json { render json: users}
end
end
и
(просмотр)
axios({
method: 'get',
url: '/home',
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }
}).then(response => console.log(response))
с заголовками json, но Я получаю
ActionController::UnknownFormat (LoginController#default is missing a template for this request format and variant.
request.formats: ["application/json"]
request.variant: []):
с ошибкой http 406 (неприемлемо)
Спасибо за вашу помощь :)
Редактировать:
Я обнаружил проблему, на самом деле мой Rails принял мой запрос как '/ homehome'. Я не знаю почему? Я меняю '/ home' на '' в параметре url ax ios, и теперь он работает, но я все еще не понимаю, что происходит ??
У меня также есть в моей веб-консоли это сообщение
A cookie associated with a cross-site resource at http://youtube.com/ was set
without the `SameSite` attribute. A future release of Chrome will only deliver
cookies with cross-site requests if they are set with `SameSite=None` and
`Secure`. You can review cookies in developer tools under
Application>Storage>Cookies and see more details at
https://www.chromestatus.com/feature/5088147346030592 and
https://www.chromestatus.com/feature/5633521622188032.