Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. [{"id":296,"nama":"Appetizer"},{"id":295,"nama":"Bahan"}]
  2.  
  3. var obj = JSON.parse(response);
  4.  
  5. let str = '[{"id":296,"nama":"Appetizer"},{"id":295,"nama":"Bahan"}]';
  6.  
  7. try {
  8. let obj = JSON.parse(str);
  9. } catch (ex) {
  10. console.error(ex);
  11. }
  12.  
  13. JSON.stringify(obj)
  14.  
  15. try {
  16. let response = await fetch('http://'+this.state.url+'/web_services/login_json/new.json', {
  17. method: 'POST',
  18. headers: {
  19. 'Accept': 'application/json',
  20. 'Content-Type': 'application/json',
  21. },
  22. body: JSON.stringify({
  23. erzap: {
  24. username: this.state.username,
  25. password: this.state.password,
  26. }
  27. })
  28. });
  29. let responseJson = await response.json();
  30.  
  31. AsyncStorage.getItem('kategoris').then((value) => {
  32. this.setState({
  33. 'kategoris': value,
  34. });
  35.  
  36. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement