asp.net-mvc - 独立运行React Native,独立运行MVC时调用MVC动作方法
问题描述
我在本机反应中有一个 fetch 调用:
componentDidMount(){
fetch("https://localhost:44379/GetShoppingItems/")
.then((res) => {
})
.catch(() => {
})
}
在 mvc 中:
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace sush.Controllers
{
public class SushController : Controller
{
public IActionResult Index()
{
return View();
}
[HttpGet]
[Route("GetShoppingItems")]
public JsonResult GetShoppingItems()
{
return Json(new { });
}
}
}
如何从我的反应原生应用程序本地调用 api?
解决方案
推荐阅读
- android - 海龟图形 APK
- node.js - 为什么 Google 身份验证可以在本地工作,但不能在 Heroku 上工作?
- debugging - Google Apps 脚本错误的第二个冒号后面的数字是多少?
- javascript - express js 服务器不允许从已部署的应用程序发布
- java - 如何在不改变样式或大小的情况下更改 JLabel 的字体?
- google-cloud-platform - 我可以使用什么 API 来查看我的 GCP 账单金额?
- git - 将分支加入新的主提交而不合并?
- node.js - 有人可以向我解释 Sequelize Join 查询吗?
- java - 在服务器崩溃/重新启动时重新启动请求(Spring Boot)
- c++ - void * 从 C 到 CPP 的分配