# Assigning innerHTML not working in some targets

**URL:** <https://discuss.hotwired.dev/t/assigning-innerhtml-not-working-in-some-targets/737>\
**Category:** General\
**Created:** [April 8, 2019, 7:22pm UTC](https://discuss.hotwired.dev/t/assigning-innerhtml-not-working-in-some-targets/737 "2019-04-08T19:22:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![compostbrain](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/compostbrain/32/496_2.png) [@compostbrain](https://discuss.hotwired.dev/u/compostbrain)\
**Post date:** [April 8, 2019, 7:22pm UTC](https://discuss.hotwired.dev/t/assigning-innerhtml-not-working-in-some-targets/737/1 "2019-04-08T19:22:19Z")

</div>

I use the fetch api to update partials with an html response. This is working in some actions but not others and I can’t figure out why. In the following code all the console.log print the expected output except for the final one:

```auto
    fetch(url)
      .then(response => response.json())
      .then(json => {
        console.log("available actions:", this.availableActionsTarget.innerHTML);
        console.log("json response", json.available_actions_form.template);
        this.availableActionsTarget.innnerHTML = json.available_actions_form.template;
        console.log("available actions after re:", this.availableActionsTarget.innerHTML);
      });

```

In other functions in my stimulus controller the innerHTML get assigned as expected but for some reason this one does not assign the innerHTML to the response.

---

<div class="post-metadata">

**Author:** ![kaspermeyer](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/kaspermeyer/32/483_2.png) [@kaspermeyer](https://discuss.hotwired.dev/u/kaspermeyer)\
**Post date:** [April 9, 2019, 8:29am UTC](https://discuss.hotwired.dev/t/assigning-innerhtml-not-working-in-some-targets/737/2 "2019-04-09T08:29:49Z")

</div>

You’ve mistyped `innerHTML` on line 6 of your example. If the code is copied directly from your project, that might be the issue 🙂

Other than that your code seems fine. I’ve posted a working example here, using your code as a template:

> Code: [Glitch :･ﾟ✧](https://glitch.com/edit/#!/stimulus-fetch-and-replace)  
> Web: [https://stimulus-fetch-and-replace.glitch.me](https://stimulus-fetch-and-replace.glitch.me)

---

<div class="post-metadata">

**Author:** ![compostbrain](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/compostbrain/32/496_2.png) [@compostbrain](https://discuss.hotwired.dev/u/compostbrain)\
**Post date:** [April 9, 2019, 10:58am UTC](https://discuss.hotwired.dev/t/assigning-innerhtml-not-working-in-some-targets/737/3 "2019-04-09T10:58:51Z")

</div>

Wow, feeling pretty dumb right now…

---

<div class="post-metadata">

**Author:** ![kaspermeyer](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/kaspermeyer/32/483_2.png) [@kaspermeyer](https://discuss.hotwired.dev/u/kaspermeyer)\
**Post date:** [April 9, 2019, 12:44pm UTC](https://discuss.hotwired.dev/t/assigning-innerhtml-not-working-in-some-targets/737/4 "2019-04-09T12:44:23Z")

</div>

Don’t! Typos are easy to overlook when you’ve been staring blindly at something for a while.
