Advertisement
osman1997

data.js

Aug 7th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import * as api from './api.js';
  2.  
  3.  
  4. const host = 'http://localhost:3030';
  5. //api.settings.host = host;
  6.  
  7. export const login = api.login;
  8. export const register = api.register;
  9. export const logout = api.logout;
  10.  
  11.  
  12.  
  13. export async function getAllListings() {
  14. return await api.get(host + '/data/cars?sortBy=_createdOn%20desc');
  15. }
  16.  
  17. export async function getListingById(id) {
  18. return await api.get(host + '/data/cars/' + id);
  19. }
  20.  
  21. export async function createListing(listing) {
  22. return await api.post(host + '/data/cars', listing)
  23. }
  24. export async function updateListing(id, listing) {
  25. return await api.put(host + '/data/cars/' + id, listing);
  26. }
  27. export async function getMyListings(userId) {
  28. return await api.get(host + `/data/cars?where=_ownerId%3D%22${userId}%22&sortBy=_createdOn%20desc`);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement