SeyZ / jsonapi-serializer

A Node.js framework agnostic library for (de)serializing your data to JSON API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using on React

jonatasdaniel opened this issue · comments

I'm trying to use the lib on React with
const JSONAPIDeserializer = require('jsonapi-serializer').Deserializer;
and then
new JSONAPIDeserializer.name({}).deserialize(data)

but I'm getting
./node_modules/jsonapi-serializer/index.js Module not found:

I'm adding the library with yarn add jsonapi-serializer.

What am I doing wrong?

hey @jonatasdaniel in your React project you could import this library using the ES Module import syntax:

So for the example above you might do:
import { Deserializer } from 'jsonapi-serializer';

Hope that helps!

commented

@sepowitz this does not work, FYI :)

commented

you can use import instead of require and the library should work just fine.

if anyone is still wondering about this, I made a small demo you may all refer to.

codesandbox