相关疑难解决方法(0)

未处理的拒绝(语法错误):输入意外结束

我正在制作一个专门用于电子邮件订阅者的组件......就像这样

import React from "react";

class SubscribeOffer extends React.Component {
constructor () {
    super();
    this.state={
        email: ""
    }
}

fillEmailToSubscribe = (event) => {
    this.setState({email: event.target.value});
}

submitEmailToSubscribe = () => {
    if (this.state.email > 3) {
        fetch('https://(myuser).list-manage.com/subscribe/post?u=(somenumber)&id=(myid)'
        ,{
            mode: 'no-cors',
            method:'POST',
            headers: {'Content-Type': 'application/json'},
            body: JSON.stringify({
                email:this.state.email
            })
        })
        .then(response => response.json())
        .then(() => {
            alert('Thank you for subscribing!');
        })
    }

}

render () {
    return (
        <div>
            <h1>Get updated upcoming events in your inbox everyday!</h1>
            <p>Would you like …
Run Code Online (Sandbox Code Playgroud)

javascript mailchimp reactjs

4
推荐指数
1
解决办法
1万
查看次数

Fetch 未检索 302 重定向调用的响应

在 ReactJS 组件中,对重定向到另一个 API 的 API 的 fetch 调用不会返回最终目的地的响应。Fetch 仅返回opaquenull 0 等响应,就好像您的调用失败一样。它甚至没有说它重定向了。但在Chrome的控制台中,“网络”选项卡清楚地显示重定向的调用成功。

            let call = fetch(encodedQueryUrl, {
                method: 'GET',
                cache: 'no-cache',
                mode: 'no-cors',
                redirect: 'follow',
                credentials: 'same-origin'
            }).then((response) => {
                console.log("Response???", response);
                return response;
            });
Run Code Online (Sandbox Code Playgroud)

因此编码的QueryURL响应标头:

Request Method: GET
Status Code: 302 
Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Headers: access-control-allow-origin
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin: *
content-length: 0
content-type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)

以及 302 响应标头:

Request Method: GET
Status Code: 200 
Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Headers: access-control-allow-origin
access-control-allow-methods: GET, POST, GET, …
Run Code Online (Sandbox Code Playgroud)

javascript ajax reactjs fetch-api

3
推荐指数
1
解决办法
1万
查看次数

如何固定将请求的模式设置为“ no-cors”?

我目前正在使用yahoo weather api来获取天气数据。我正在错误以下。请帮忙。

通过CORS策略阻止从原点“ http:// localhost:3000 ” 访问“ https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale,ca&format=json ”的提取进行预检请求未通过访问控制检查:请求的资源上不存在“ Access-Control-Allow-Origin”标头。如果不透明的响应满足您的需求,请将请求的模式设置为“ no-cors”,以在禁用CORS的情况下获取资源。

我曾尝试过使用google,但没有一种解决方案对我有用

javascript oauth reactjs

1
推荐指数
2
解决办法
7992
查看次数

对被 CORB 阻止的 html 资源获取的 no-cors 不透明请求

我正在尝试 从using模式中获取html位于 url 的文件,但响应被 CORB(跨源读取阻塞)阻止。https://sub.app.test/htmlhttps://app.testno-cors

fetch('https://sub.app.test/html', { mode: 'no-cors'})
Run Code Online (Sandbox Code Playgroud)

为什么?

fetch cors cross-origin-read-blocking

1
推荐指数
1
解决办法
750
查看次数