Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
Guessjs - How to get routes and probabilities with guess-webpack and guess-webpack/api in vuejs?

I have run:

npm i guess-webpack

In my webpack.mix.js I have:

const { GuessPlugin } = require('guess-webpack');

mix.webpackConfig({
plugins: [
new GuessPlugin({
    GA: '123456789',
    jwt: {
        private_key: "-----BEGIN PRIVATE KEY-----\nSomething!!!\n-----END PRIVATE KEY-----\n",
        client_email: "example@example.com",
    },
    //debug: true,
    runtime: {
        delegate: false
    }
}),

Till now, it is working and when I uncomment the debug: true, it returns all the routes and probabilities like so:

Initial mapping between routes and probability
{
    "/": [{
        "route": "/example-1",
        "probability": 0.16031746031746033
    }, {
        "route": "/example-2",
        "probability": 0.10031746031746033
    }]
    ...
    ...
    ...
}

But now the problem is that when I want to get the data from guess() function which is inside guess-webpack/api into my vue application in order to get the routes and probabilities, it returns:

[Vue warn]: Error in mounted hook: "TypeError: (intermediate value).__GUESS__ is undefined"
.
.
.
TypeError: (intermediate value).__GUESS__ is undefined

My code that generates the above error is:

import Vue from 'vue';

new Vue({
el: '#app',
data() {
    return {}
},
mounted() {
    const { guess } = require('guess-webpack/api');
    if (typeof window !== 'undefined') {
        console.log(guess()); //This is undefined!
    }
}

I have access to `__GUESS__` and its method which is `p` in my console but when I run `__GUESS__.p()`, it returns `undefined`.

What's inside guess-webpack/api:

export const guess = (params: any) =>
  ((typeof window === 'undefined' ? global : window) as any).__GUESS__.guess(params);

How to get routes and probabilities with guess-webpack and guess-webpack/api in vuejs?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda