Categories
Mastering Development

Not able to save my new playlist in my Spotify account (I get an empty list of tracks)

I get the following error when doing a POST on my Spotify app: Uncaught TypeError: Cannot read property ‘then’ of undefined This is my function in my util module Spotify (I added return statements, still get that message): savePlaylist1(name, trackUris) { if (!name || !trackUris.length) { return; } const accessToken = Spotify.getAccessToken(); const headers = […]

Categories
Mastering Development

Cannot empty array in ReastJS useEffect hook

I’m having this table view in React where I fetch an array from API and display it. When the user types something on the table search box, I’m trying to clear the current state array and render the completely new result. But for some reason, the result keeps getting appended to the current set of […]

Categories
Mastering Development System & Network

Erro Failed to connect to localhost port 80: Connection refused using Guzzle on Laravel

I have a project with only one container. I’m trying to make a request with Guzzly in laravel to simulate an external API When I set base_url with my ipv4 (http://192.168.15.49) it makes the request without errors, however when I use http: // localhost it gives the error "connection refused" (Error Failed to connect to […]

Categories
Mastering Development

FutureBuilder always return Instance of Future

I try to display a custom message when user logs or when log fail. My post api call returns nothing, so I wanted to base on response status code to know if log went well or not. I did something like in my api : Future<Response> login(String email, String password) async { final http.Response response […]

Categories
Mastering Development

API not updating table field – React Native App, AWS API and DynamoDB table

Trying to update my DynamoDB table with my “Update” API. It is just not working. “Update” API will update the field “status” from “New” to “Read”. No issue with the API as I checked it on Postman and it updates the field correctly. export const updateNotifications = (id) => { if(id !== null){ const config […]

Categories
Mastering Development

Discord HTTPS POST with C

I’m trying to build a Discord API with C (libdiscord it’s constantly crashing). I have found this promosing code (found here): #include <stdio.h> /* printf, sprintf */ #include <stdlib.h> /* exit */ #include <unistd.h> /* read, write, close */ #include <string.h> /* memcpy, memset */ #include <sys/socket.h> /* socket, connect */ #include <netinet/in.h> /* struct […]

Categories
Mastering Development

Python Requests login: i have error 403 but the request looks correct

I am trying to login into www.zalando.it using the requests library, but every time I try to post my data I am getting a 403 error. I saw in the network tab from Zalando and the login call and is the same. These are just dummy data, you can test creating a test account. Here […]

Categories
Mastering Development

Swift 5 & Alamofire 5 : GET method ERROR: Alamofire.AFError.URLRequestValidationFailureReason.bodyDataInGETRequest(22 bytes)

I am trying to get records from Database using Alamofire. I am sending parameters in GET request as below. let headers : HTTPHeaders = [“x-access-token”: “\(t)”,”username”:”\(Base.sharedManager.user)”,”password”:”\(Base.sharedManager.pass)”] let parm : [String: Any] = [“search_str” : self!.searchStr] // let searchUrl = Base.sharedManager.URL+”questions/get/”+self!.searchStr let searchUrl = Base.sharedManager.URL+”questions/get/” AF.request(searchUrl, method: .get, parameters: parm, encoding:JSONEncoding.default , headers: headers, interceptor: nil).response […]

Categories
Mastering Development

How to resolve CORS policy issue in Ionic Angular app?

I am trying to execute the below function in my Ionic Angular app, cloudFunctionUrl is a cloud function I have in my firebase project: import { HttpClient } from ‘@angular/common/http’; private http: HttpClient like(post) { this.http.post(‘cloudFunctionUrl’, JSON.stringify(body), { responseType: ‘text’ }).subscribe((data) => { console.log(data); }, (error) => { console.log(error); }); } To get over the […]

Categories
Mastering Development

Python requests with bearer token returns 401

I have api when called using Postman returns 200 and expected data. Similarly when urllib is used it returns 200 but fails when used requests. Note – All methods work correctly on external url but return 401 on localhost urllib code(returns 200): r = request.Request(myUrl) r.add_header(‘Accept’, ‘application/json’) r.add_header(‘Authorization’, f’Bearer {self.AUTH_TOKEN}’) response = request.urlopen(r, context=self.ctx) requests […]