json - 从 localhost 对象获取数据发生错误
问题描述
嗨,我创建了一个后端并在 localhost 上获取它,如图所示:
我在codepen中获取它,但它不起作用。
fetch(`localhost:5000/products`)
.then(response => response.json())
.then(data => console.log(data))
.catch((error) => {
console.error('Error:', error);
});
喜欢这个链接:https ://codepen.io/nutkin/pen/MWpMzMv?editors=0012
有谁知道会发生什么?
解决方案
嗨,我Moesif Origin & CORS Changer by Moesif
在 firefox 扩展程序中安装后,它可以工作。一些后端不支持共享数据。
推荐阅读
- javascript - 验证在 Jquery 和 rails 中选择的复选框的长度
- android - 在没有 Google Play 的情况下更新 Android 应用程序
- java - 以整数计算的双精度表达式
- java - android上发布版本中的对象反序列化
- cakephp - CakePHP 集成TestTrait,测试文件上传
- wix - WIX IIS WebAppPool 未正确设置
- javascript - 选择后反应材料选择不显示值
- java - 通过 Android 套接字发送和接收字节的两个问题:
- c# - 在同一列中分组不同的值
- php - 如何在 WordPress 主题中修复 index.php 上的“id=error-page”默认值