我正在使用 expo 创建 MERN React 本机移动应用程序,但我对如何使用 Express 连接 REST API 感到困惑。下面是代码。
应用程序.js
import React from "react";
import {
StyleSheet,
Text,
View,
TextInput,
TouchableOpacity,
SafeAreaView,
} from "react-native";
class Form extends React.Component {
constructor() {
super();
this.State = {
title: "",
description: "",
};
}
getInput(text, field) {
if (field == "title") {
this.setState({ title: text });
} else if (field == "description") {
this.setState({ description: text });
}
//console.warn(text)
}
submit() {
let collection = {};
(collection.title = this.state.title),
(collection.description …Run Code Online (Sandbox Code Playgroud)