Rest api (erpnext-reactnative)


Anyone here can help? I created a mobile app that will login to ERP. Im using React Native but im having errors.

Source?

Edit: hate to keep reminding everyone, but this is an open source community with a focus on sharing, not a one-way help forum.

1 Like

I was going to ask @sheerland what this app was all about and what it does etc before your message came in.

@sheerland I hope you understand what point rmehta is making ??

import React from ‘react’;
import { StyleSheet, Text, View, Button } from ‘react-native’;

export default class App extends React.Component {

ping(){

fetch(‘http://192.168.254.122:8080/api/method/sheerland.ping’, {
method: ‘GET’,
}).done(function(response){
console.log(response._bodyText);
});

// fetch(‘http://192.168.254.122:8080/api/method/sheerland.ping’)
// .then(response => response.json())
console.log(“1”);

}

login(){

fetch(‘http://192.168.254.122:8080/api/method/login:’, {
method: ‘POST’,

usr: 'Administrator',                                 
pwd: 'frappe',

}).done(function(response){
console.log(response);
});;
console.log(“2”);
}

// auth(){

// fetch(‘http://192.168.254.122:8080/api/method/frappe.auth.get_logged_user’, {
// method: ‘GET’,

// }).done(function(response){
// console.log(response);
// });;
// console.log(“3”);
// }

render() {
return (


----------------------------------------------

  </View>
);

}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: ‘#fff’,
alignItems: ‘center’,
justifyContent: ‘center’,
},
});

REACT NATIVE CODE

-- coding: utf-8 --

from future import unicode_literals

version = ‘0.0.1’

import frappe
from frappe import _

@frappe.whitelist(allow_guest=True)
def ping():
return ‘pong’

INIT.PY FILE

@olamide_shodunke this app i build can call a function on erp which can be executed via mobile app. With a press of a button it will return a response on what you have returned on the function.

This is neither useful, not read-able.

Source can be found here https://frappe.io/docs/user/en/guides/integration/rest_api im just only following it. Source for the mobile application can be seen on the screenshot ive sent.

Isn’t the first capital A a mistake in your username?

User account username is "Administrator’
password is “frappe”

Hi

You fixed? If yes pls share. Thanks

1 Like

Its done. This is the code.

fetch(‘http://192.168.0.12:8080/api/method/login?usr=Administrator&pwd=frappe’, {
method: ‘POST’
}).done(function(response){
console.log(response);
});;

Done solving it @rmehta :slight_smile:

3 Likes