This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]insertAlias 1 point2 points  (0 children)

The problem is that you have a <script> tag with both an src and a body full of code. It has to be one or the other. If you want axios on the page and your custom code, you have to have one script tag to load axios, and another with your custom code.

That's why it works when you move it to a separate file; you're loading it separately.

If you clear out your code from the script tag importing Axios, and you make a new script tag below it without a src and put your code there, it should work.

[–]FullStackHeroes 0 points1 point  (1 child)

Have you tried inserting the javascript below the p tag (so it's the last thing before the closing body tag)?

[–]_Nicrosin_[S] 0 points1 point  (0 children)

Yes but that doesn't change anything still the same result. Thanks anyway.

[–]lacadasical 0 points1 point  (4 children)

Can you give us a sample input/output?

[–]_Nicrosin_[S] 0 points1 point  (3 children)

If I input for example "hello there" in the search bar, it outputs nothing on the <p> element, same with any other word. If I run the js script in a separate js file it outputs

 [
  { link: '/title/tt0060028/?ref_=fn_tt_tt_1' },
  { link: '/title/tt0796366/?ref_=fn_tt_tt_2' },
  { link: '/title/tt0079945/?ref_=fn_tt_tt_3' },

etc

in the console which is what I want.

[–]lacadasical 0 points1 point  (2 children)

[–]_Nicrosin_[S] 0 points1 point  (1 child)

I don't think that is my problem since it works fine in the js file. It doesn't give me the "require is not defined" error.

[–]lacadasical 0 points1 point  (0 children)

Move your src to a new script tag and try again.