Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
Can't send patch request to React Native

The patch request is not sent, the server returns 422 code. The Postman patch works fine. Maybe I am not sending the request correctly.Here is my EditingPatientScreen code:

function EditingPatientScreen({route, navigation}) {

  const {item} = route.params;

  const [values, setValues] = useState({});

  const handleChange = (name, e) => setValues(a => ({
    ...a,
    [name]: e
  }));


  const onSumbit = (id) => {
    console.log(id)
    patient.put(id)
      .then(({ data }) => {
        navigation.navigate("HomeScreen");
        console.log(values)
      }).catch(e => {
      console.log(e);
    });
  };

  return (
    <>
      <View style={{ flex: 1, backgroundColor: `#ffffffff` }}>
        <View style={{ backgroundColor: `#ffffff` }}>
          <TextInput
            style={[styles.text_input]}
            label={"Имя и Фамилия"}
            onChangeText={ text =>handleChange("fullname", text)}
            value={values.fullname}
            autoFocus
          />
          <TextInput
            style={styles.text_input}
            label={" Номер телефона"}
            keyboardType="phone-pad"
            dataDetectorType={"phoneNumber"}
            onChangeText={ text =>handleChange( "phone", text)}
            value={values.phone}
            autoFocus
          />
          <View style={styles.viewButton}>
            <View style={styles.buttonContainer}>
              <TouchableOpacity style={styles.touchableOpacity} onPress={() => onSumbit(item._id)}>
                <Text style={styles.touchableOpacityText}><MaterialIcons name={"done"} size={17}/> Сохранить</Text>
              </TouchableOpacity>
            </View>
          </View>
        </View>
      </View>
    </>
  );
}

export default EditingPatientScreen;

Here is my code from patients.js. I think I did the right thing here

import axios from "axios";

export default {
  post: values => axios.post('http://localhost:5000/patients', values),
  show: id => axios.get('http://localhost:5000/patients/' + id),
  get: () => axios.get('http://localhost:5000/patients'),
  remove: id => axios.delete('http://localhost:5000/patients/ ' + id),
  put: id => axios.patch('http://localhost:5000/patients/ ' + id),
}

How to solve the problem?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is an extra space on your URL, it should look like this:

put: id => axios.patch('http://localhost:5000/patients/' + id),
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!