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

112
Visualizações
fetch empty body when using opera

I am trying to call my restapi (created with java spring) to authorize the user in vuejs. To do that I call an HTTP request using fetch. This works fine in chrome and firefox, however not in Opera andEdge.

This is the code I am executing in the mounted() method:

      fetch(
          'http://localhost:8083/oauth2/user',
          {
            method: 'GET',
            headers: {
              'Authorization': localStorage.accesstoken,
              'Accept': 'application/json',
              'Content-Type': 'application/json',
            },
          }
      )
          .then(res => {
                console.log("Status: " + res.status)
                if (res.status === 200) {
                  return res.json();
                } else {
                  console.log(res.text())
                }
              }
          )
          .then(res => {
                console.log("jsondata: " + res)
              }
          )
          .catch((e) => {
                console.log(e)
              }
          )

Running in Opera:

Status: 200

SyntaxError: Unexpected end of JSON input

Response: "This request has no response data available."

Running in Chrome

Status: 200
jsondata: [object Object]

Response: <correct JSON object it's suppose to have>

This is the java spring boot I call:

    @CrossOrigin
    @GetMapping("/oauth2/user")
    ResponseEntity<String> getUserInfo(@RequestHeader("Authorization") String authentication){
        try {
            PrimeUser user = authenticateUser(authentication);
            assert user != null;
            return ResponseEntity.ok()
                    .body(new Gson().toJson(user));
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseEntity.internalServerError()
                    .body(e.getMessage());
        }
    }

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