Skip to main content
removeu 55 caracteres do conteúdo
Fonte Link
novic
  • 36,7mil
  • 4
  • 32
  • 70
div id="app">
    <ul>
        <li v-for="album in albuns">
            {{albuns.Id }} {{albuns.Nome}}
        </li>
    </ul>
</div>
<script src="https://unpkg.com/vue"></script> 

<script>
    const app = new Vue({
        el: '#app',
        data: {
            albuns: []
        },
        created() {
            fetch('http://localhost:59385/Album/listaralbuns')
                .then(Response => Response.json())
                .then(json => {
                    this.albuns = json.albuns
                })
        }
    })
</script>


Api 

Api

[HttpGet]
        [Route("album/listaralbuns")]
        public HttpResponseMessage ListarAlbuns(Album album)
        {
            var albumService = new AlbumService();
            var listaAlbuns = albumService.obterAlbum();

            return Request.CreateResponse(HttpStatusCode.OK, listaAlbuns, Configuration.Formatters.JsonFormatter);
}

A api traz os dados corretos debugando pelo visual studiolistaAlbuns, mas no retorno os seguintes erros:

>Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resourceConfiguration. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabledFormatters.

>Teste:1 Uncaught (in promiseJsonFormatter) TypeError: Failed to fetch

;
Desde já obrigado}

A api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Teste:1 Uncaught (in promise) TypeError: Failed to fetch

div id="app">
    <ul>
        <li v-for="album in albuns">
            {{albuns.Id }} {{albuns.Nome}}
        </li>
    </ul>
</div>
<script src="https://unpkg.com/vue"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            albuns: []
        },
        created() {
            fetch('http://localhost:59385/Album/listaralbuns')
                .then(Response => Response.json())
                .then(json => {
                    this.albuns = json.albuns
                })
        }
    })
</script>


Api 

[HttpGet]
        [Route("album/listaralbuns")]
        public HttpResponseMessage ListarAlbuns(Album album)
        {
            var albumService = new AlbumService();
            var listaAlbuns = albumService.obterAlbum();

            return Request.CreateResponse(HttpStatusCode.OK, listaAlbuns, Configuration.Formatters.JsonFormatter);
}

A api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

>Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

>Teste:1 Uncaught (in promise) TypeError: Failed to fetch


Desde já obrigado
div id="app">
    <ul>
        <li v-for="album in albuns">
            {{albuns.Id }} {{albuns.Nome}}
        </li>
    </ul>
</div>
<script src="https://unpkg.com/vue"></script> 

<script>
const app = new Vue({
    el: '#app',
    data: {
        albuns: []
    },
    created() {
        fetch('http://localhost:59385/Album/listaralbuns')
            .then(Response => Response.json())
            .then(json => {
                this.albuns = json.albuns
            })
    }
})
</script>

Api

[HttpGet]
[Route("album/listaralbuns")]
public HttpResponseMessage ListarAlbuns(Album album)
{
    var albumService = new AlbumService();
    var listaAlbuns = albumService.obterAlbum();

    return Request.CreateResponse(HttpStatusCode.OK, 
        listaAlbuns, 
        Configuration.Formatters.JsonFormatter);
}

A api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Teste:1 Uncaught (in promise) TypeError: Failed to fetch

adicionou 423 caracteres ao conteúdo
Fonte Link
div id="app">
    <ul>
        <li v-for="album in albuns">
            {{albuns.Id }} {{albuns.Nome}}
        </li>
    </ul>
</div>
<script src="https://unpkg.com/vue"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            albuns: []
        },
        created() {
            fetch('http://localhost:59385/Album/listaralbuns')
                .then(Response => Response.json())
                .then(json => {
                    this.albuns = json.albuns
                })
        }
    })
</script> 


Api 

[HttpGet]
        [Route("album/listaralbuns")]
        public HttpResponseMessage ListarAlbuns(Album album)
        {
            var albumService = new AlbumService();
            var listaAlbuns = albumService.obterAlbum();

            return Request.CreateResponse(HttpStatusCode.OK, listaAlbuns, Configuration.Formatters.JsonFormatter);
}

A api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

>Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

>Teste:1 Uncaught (in promise) TypeError: Failed to fetch


Desde já obrigado

A api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Teste:1 Uncaught (in promise) TypeError: Failed to fetch

Desde já obrigado

div id="app">
    <ul>
        <li v-for="album in albuns">
            {{albuns.Id }} {{albuns.Nome}}
        </li>
    </ul>
</div>
<script src="https://unpkg.com/vue"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            albuns: []
        },
        created() {
            fetch('http://localhost:59385/Album/listaralbuns')
                .then(Response => Response.json())
                .then(json => {
                    this.albuns = json.albuns
                })
        }
    })
</script>

A api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Teste:1 Uncaught (in promise) TypeError: Failed to fetch

Desde já obrigado

div id="app">
    <ul>
        <li v-for="album in albuns">
            {{albuns.Id }} {{albuns.Nome}}
        </li>
    </ul>
</div>
<script src="https://unpkg.com/vue"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            albuns: []
        },
        created() {
            fetch('http://localhost:59385/Album/listaralbuns')
                .then(Response => Response.json())
                .then(json => {
                    this.albuns = json.albuns
                })
        }
    })
</script> 


Api 

[HttpGet]
        [Route("album/listaralbuns")]
        public HttpResponseMessage ListarAlbuns(Album album)
        {
            var albumService = new AlbumService();
            var listaAlbuns = albumService.obterAlbum();

            return Request.CreateResponse(HttpStatusCode.OK, listaAlbuns, Configuration.Formatters.JsonFormatter);
}

A api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

>Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

>Teste:1 Uncaught (in promise) TypeError: Failed to fetch


Desde já obrigado
adicionou 12 caracteres ao conteúdo
Fonte Link
neves
  • 5,9mil
  • 13
  • 22
  • 56

souSou novo usando o Vue.js e estou com um problema para pegar o retorno de uma api, meu. Meu código é o seguinte:

div id="app">

    {{albuns.Id }} {{albuns.Nome}}

const app = new Vue({ el: '#app', data: { albuns: [] }, created() { fetch('http://localhost:59385/Album/listaralbuns') .then(Response => Response.json()) .then(json => { this.albuns = json.albuns }) } })
div id="app">
    <ul>
        <li v-for="album in albuns">
            {{albuns.Id }} {{albuns.Nome}}
        </li>
    </ul>
</div>
<script src="https://unpkg.com/vue"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            albuns: []
        },
        created() {
            fetch('http://localhost:59385/Album/listaralbuns')
                .then(Response => Response.json())
                .then(json => {
                    this.albuns = json.albuns
                })
        }
    })
</script>

aA api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Teste:1 Uncaught (in promise) TypeError: Failed to fetch

Teste:1 Uncaught (in promise) TypeError: Failed to fetch

desdeDesde já obrigado

sou novo usando o Vue.js e estou com um problema para pegar o retorno de uma api, meu código é o seguinte

div id="app">

    {{albuns.Id }} {{albuns.Nome}}

const app = new Vue({ el: '#app', data: { albuns: [] }, created() { fetch('http://localhost:59385/Album/listaralbuns') .then(Response => Response.json()) .then(json => { this.albuns = json.albuns }) } })

a api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Teste:1 Uncaught (in promise) TypeError: Failed to fetch

desde já obrigado

Sou novo usando o Vue.js e estou com um problema para pegar o retorno de uma api. Meu código é o seguinte:

div id="app">
    <ul>
        <li v-for="album in albuns">
            {{albuns.Id }} {{albuns.Nome}}
        </li>
    </ul>
</div>
<script src="https://unpkg.com/vue"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            albuns: []
        },
        created() {
            fetch('http://localhost:59385/Album/listaralbuns')
                .then(Response => Response.json())
                .then(json => {
                    this.albuns = json.albuns
                })
        }
    })
</script>

A api traz os dados corretos debugando pelo visual studio, mas no retorno os seguintes erros:

Access to fetch at 'http://localhost:59385/Album/listaralbuns' from origin 'http://localhost:59841' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Teste:1 Uncaught (in promise) TypeError: Failed to fetch

Desde já obrigado

Fonte Link
Carregando