Giter Club home page Giter Club logo

api's People

Contributors

claudiolcastro avatar emanuelgsouza avatar guilouro avatar lucaskahl avatar luizeboli avatar sergioflores-j avatar willianjusten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

api's Issues

Unexpected token on yarn develop

node version: v12.22.7
npm version: 6.14.15
OS: Windows10 - WSL2 Ubuntu 20.04

after install all dependencies with
yarn install

and run
yarn develop

I get the error:

image

Strapi Error: {"data":null,"error":{"status":400,"name":"ValidationError","message":"Invalid payload submitted for the creation of an entity of type publisher. Expected an object, but got undefined","details":{}}}

Descrição do problema:

Ao usar o método service.create de Publisher, dentro do custom service Populate, recebo o seguinte erro no console:

{"data":null,"error":{"status":400,"name":"ValidationError","message":"Invalid payload submitted for the creation of an entity of type publisher. Expected an object, but got undefined","details":{}}}

Gostaria de ajuda para entender e resolver este problema.

Abaixo segue o código do custom service Populate:

"use strict";

/**
 * populate service.
 */

const axios = require("axios");
const slugify = require("slugify");

async function getGameInfo(slug) {
  const jsdom = require("jsdom");
  const { JSDOM } = jsdom;
  const body = await axios.get(`https://www.gog.com/game/${slug}`);
  const dom = new JSDOM(body.data);

  const description = dom.window.document.querySelector(".description");

  return {
    rating: "BR0",
    short_description: description.textContent.slice(0, 160),
    description: description.innerHTML,
  };
}

module.exports = ({ strapi }) => ({
  async populate(params) {
    const gogApiUrl = `https://www.gog.com/games/ajax/filtered?mediaType=game&page=1&sort=popularity`;

    const {
      data: { products },
    } = await axios.get(gogApiUrl);

    const publisher = {
      name: products[0].publisher,
      slug: slugify(products[0].publisher).toLowerCase(),
    };

    console.log(strapi);

    await strapi.service("api::publisher.publisher").create(publisher);

    return publisher;

    // console.log(await getGameInfo(products[0].slug));
  },
});

No console os objetos products e publisher estão no formado e com os dados correspondentes ao esperado, o erro ocorre ao rodar o curl -X POST http://localhost:1337/api/games/populate.

Antes de desabilitar a opção Draft/Publish dentro de Advanced Settings da tabela Publisher, o erro era:

[2022-01-12 11:03:39.380] error: Cannot set property 'publishedAt' of undefined
TypeError: Cannot set property 'publishedAt' of undefined

Após desabilitar essa opção dentro da tabela, o erro passa a ser:

{"data":null,"error":{"status":400,"name":"ValidationError","message":"Invalid payload submitted for the creation of an entity of type publisher. Expected an object, but got undefined","details":{}}}

Gostaria de ajuda para avançar este estágio.

Desde já, obrigado a todos.

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.