Closed rcackerman closed 1 year ago
@rcackerman Take another close look at Shorthand methods. Now compare that to your “This doesn’t work” code snippet, specifically the following bit:
const request = new post(this.element.action, { body: payload, responseKind: "json" })
const response = await request.perform();
The correct invocation looks as follows:
const response = await post(this.element.action, { body: payload, responseKind: "json" });
In the short version form you skip constructing a Request
object, so you don’t need new …
/request.perform()
as the short versions do that for you.
@rcackerman Did you solve your problem based on @ur5us answer? I'll close the issue, but if you still are facing the problem we can reopen it, thank you!
I'm upgrade a Rails 6 application from using webpacker to jsbundling with webpack 5. I'm running into a very strange error where
get
,patch
,post
, etc result in aTypeError
, while theFetchRequest
class does not. The exact error is that<webpack module>.post is not a constructor
.I managed to reproduce the error in a simple test application using Rails 6 and then following the migration instructions from jsbundling. There's a simple form:
This doesn't work:
but this does:
My
package.json
looks like this:And my webpack config looks like: