mollie / mollie-api-node

Official Mollie API client for Node
http://www.mollie.com
BSD 3-Clause "New" or "Revised" License
237 stars 63 forks source link

fs.readFileSync is not a function #25

Closed joeydebreuk closed 7 years ago

joeydebreuk commented 7 years ago

Hi Guys,

I am building an reactjs app and I am planning to use Mollie using this rep but something goes wrong with using the fs functions in the code of mollie-api-node.

Im getting the following error:

Uncaught TypeError: fs.readFileSync is not a function at Client.module.exports.Client.callRest (bundle.js:69617) at Payments.module.exports.Base.create (bundle.js:75793) at Object. (bundle.js:10888) at webpack_require (bundle.js:556) at fn (bundle.js:87) at Object. (bundle.js:591) at webpack_require (bundle.js:556) at bundle.js:579 at bundle.js:582

using the following code:

var Mollie = require("mollie-api-node");
var mollie = new Mollie.API.Client;
mollie.setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");

mollie.payments.create({
    amount:      10.00,
    description: "My first API payment",
    redirectUrl: "https://webshop.example.org/order/12345/",
    webhookUrl:  "https://webshop.example.org/mollie-webhook/"
}, function (payment) {
    mollie.response.writeHead(302, { Location: payment.getPaymentUrl() })
});

Is there anyone with a similar problem?

Thanks!

dabroek commented 7 years ago

This is a webpack issue. Add the following to your webpack config file:

node: {
  fs: 'empty'
}