I'm new in NodeJS I wanted to do the equivalent of this code which is coded in Ruby Rails.It is a survey that I must implement with my frontend
class SurveysController < ApplicationController
before_action :authorize, only: [:create, :update, :destroy, :index]
before_action :set_user, only: [:create, :destroy, :index]
before_action :set_survey, only: [:show, :update, :destroy]
# GET /surveys
def index
@surveys = @user.surveys
render json: @surveys
end
# GET /surveys/1
def show
render json: @survey
end
# POST /surveys
def create
@survey = Survey.new(
title: survey_params[:title],
sub_title: survey_params[:sub_title],
questions: survey_params[:questions].to_json,
user: @user
)
Aucun commentaire:
Enregistrer un commentaire