Giter Club home page Giter Club logo

Comments (4)

samselikoff avatar samselikoff commented on May 18, 2024

First, it looks you're mocking out a JSON:API backend so I would use the JSONAPISerializer:

import { JSONAPISerializer } from 'miragejs'

new Server({
  serializers: {
    application: JSONAPISerializer
  }
})

Second, the response to /api/companies does seem wrong... first step in debugging these is to do a server.db.dump() right before your API call, and make sure the database looks as you expect. (Sometimes I do window.server = server to make this easy). Let me know what it says and I can help from there!

from miragejs.

dugajean avatar dugajean commented on May 18, 2024

@samselikoff Thanks on the advice for adding the serializer; That helped! Are there plans for a JSON-LD serializer in the future?

For the information you requested, this is the output (the companies part):

companies: Array(5)
  0: {jobIds: Array(10), logo: undefined, name: undefined, id: "1"}
  1: {jobIds: Array(10), logo: undefined, name: undefined, id: "2"}
  2: {jobIds: Array(10), logo: undefined, name: undefined, id: "3"}
  3: {jobIds: Array(10), logo: undefined, name: undefined, id: "4"}
  4: {jobIds: Array(10), logo: undefined, name: undefined, id: "5"}

from miragejs.

dugajean avatar dugajean commented on May 18, 2024

I was using the faker.js API incorrectly. It's companyName, not name. Thanks for the help!

from miragejs.

samselikoff avatar samselikoff commented on May 18, 2024

Awesome, glad you found it!

Haven't heard of JSON LD but if it's popular enough we can add it. For now if I was building a JSON LD app I'd probably make my own application serializer by extending the base Serializer or RestSerializer class, or even JSONAPISerializer (or copying it + changing what I need).

You can take a look at the source and see if you'd like to do that:

from miragejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.