I creating module for guest wishlist on Magento 2. There is mage library contains many js files. One of them is dataPost.js in directory mage. I need overwrite function postData in it. This is jQuery Widget.

What I have:


var config = {
  map: {
   '*': {
     'mage/dataPost': '<VENDOR_MODULE>/js/wishlist-data-post'


], function($) {
  'use strict';

  $.widget('custom.dataPost', $.mage.dataPost, {
    postData: function(params) {
      return this._super();

  return $.custom.dataPost;

I get error:

Uncaught TypeError: base is not a constructor

I cannot do it like there because it isn't Magento_UI: Magento2 customer account navigation wishlist Items how to display in phtml

No right answer: https://stackoverflow.com/questions/40713696/not-able-to-override-collapsible-js-in-magento-2

What I doing wrong?

  • 1
    Hi, did you find any way to override dataPost.js?
    – vedu
    Commented Mar 19, 2018 at 14:53
  • Check my answear
    – Patryk
    Commented Mar 22, 2018 at 7:56

1 Answer 1


There are 2 options available. I use first, because was simpler and work fine. What was wrong - I used map not mixins so this._super(); don't any parent - we override file than we extend.

Solution - first option

Copy lib/web/mage/dataPost.js to the theme as THEME/web/js/mage/dataPost.js Edit THEME/requirejs-config.js with this:

var config = {
  map: {
   '*': {
     'mage/dataPost': 'js/mage/dataPost'

Now body of this file is editable in theme and used in system as default.

IMPORTANT: Remove symlink from pub\static, otherwise you stuck with old file ;( This is why we have many problem because symlinks don't automatically update after are created.

Better options is to use mixins in THEME/requirejs-config.js but for me, and this file, not work correct.

  • i apply this but getting in console error
    – Rv Singh
    Commented Mar 22, 2019 at 9:01
  • What error? It will help others having issues with this.
    – Patryk
    Commented Mar 25, 2019 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.