如何解决如何从React Native App将我的length变量发送到我的HTTPS服务器
我正在尝试使用滑动条功能从HTTPS服务器生成图像,但是我的提取功能存在问题。该应用程序应该具有确定长度变量的滑块,该变量将被发送到服务器,服务器将根据该长度进行更新并生成图像。
{{ url('storage/app/'.$filename) }}
这是将保留图像的另一个组件
import { StatusBar } from 'expo-status-bar';
import React,{Component} from 'react';
import { StyleSheet,Text,View,Slider } from 'react-native';
import Dipole2 from './Components/Dipole2';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
length : 2
}
};
render() {
return (
<View style = {styles.LengthContainer}>
<Dipole2></Dipole2>
<Text style={styles.number}> Length of Dipole </Text>
<Text style={styles.number}> {this.state.length.toFixed(1)}</Text>
<Slider
style = {{width: 300}}
maximumValue={10}
minimumValue={0.1}
minimumTrackTintColor="#308ecc"
maximumTrackTintColor="#000000"
step={0.1}
value={this.state.length}
onValueChange={length => this.setState({length})}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,backgroundColor: '#fff',alignItems: 'center',justifyContent: 'center',},LengthContainer: {
flex: 400,justifyContent: 'flex-end',marginBottom: 200,ImageContainer: {
flex: 500,marginBottom: 600,borderColor: 'black',number: {
fontSize: 25,textAlign: 'center',margin: 10,});
let data = {
method: 'POST',body: ({ length }),headers: {
'Content-Type': 'text/html',}
}
return fetch('https://dipolepattern.azurewebsites.net/api/HttpTrigger1',data)
.then(response => response.json()) // promise
.then(json => dispatch(receiveAppos(json)))
解决方法
传递给body
的{{1}}的{{1}}字段必须是一个字符串。因此,您可以将options
替换为fetch
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。