Response is coming as */* instead of turbo_stream in rails 7

Viewed 18

when hitting the stimulus controller it's going to the rails stimulus controller but the request is coming as */* but I want this request as turbo_stream, so how can i do that. app/views/stimulus/index.html.erb

<div data-controller="toggle" data-toggle-url-value="<%= root_path %>">
<div>
       <p class="mt-5">Copy text content</p>
       <input type="text" data-toggle-target="txt"/>
       <button data-action="click->toggle#copy">Copy</button>
</div>

app/controllers/stimulus_controller.rb

def index
   
end

app/javascript/controllers/stimulus_controller.js

static targets = ["txt"]
static values = { url: String }

connect() {
    this.hideBtnTarget.hidden = true
    console.log(this.urlValue);
    fetch(this.urlValue).then((success) => {
      console.log(success);
    }).catch((e) => {
      console.log(e);
    })
  }

copy(){
    let txt = this.txtTarget
    txt.select()
    document.execCommand("copy")
    txt.value = ""
  }

I want a response as turbo_stream instead of */* .

thanks!

0 Answers
Related